Skip to content

Commit bf98d23

Browse files
committed
check lib command line option when deciding if program structure can be reused
1 parent 7555f60 commit bf98d23

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

src/compiler/program.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,7 @@ namespace ts {
473473
(oldOptions.configFilePath !== options.configFilePath) ||
474474
(oldOptions.baseUrl !== options.baseUrl) ||
475475
(oldOptions.maxNodeModuleJsDepth !== options.maxNodeModuleJsDepth) ||
476+
!arrayIsEqualTo(oldOptions.lib, options.lib) ||
476477
!arrayIsEqualTo(oldOptions.typeRoots, oldOptions.typeRoots) ||
477478
!arrayIsEqualTo(oldOptions.rootDirs, options.rootDirs) ||
478479
!equalOwnProperties(oldOptions.paths, options.paths)) {

src/harness/unittests/tsserverProjectSystem.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1898,6 +1898,64 @@ namespace ts.projectSystem {
18981898
projectService.closeExternalProject(projectName);
18991899
projectService.checkNumberOfProjects({});
19001900
});
1901+
1902+
it("correctly handles changes in lib section of config file", () => {
1903+
const libES5 = {
1904+
path: "/compiler/lib.es5.d.ts",
1905+
content: "declare const eval: any"
1906+
};
1907+
const libES2015Promise = {
1908+
path: "/compiler/lib.es2015.promise.d.ts",
1909+
content: "declare class Promise<T> {}"
1910+
};
1911+
const app = {
1912+
path: "/src/app.ts",
1913+
content: "var x: Promise<string>;"
1914+
};
1915+
const config1 = {
1916+
path: "/src/tsconfig.json",
1917+
content: JSON.stringify(
1918+
{
1919+
"compilerOptions": {
1920+
"module": "commonjs",
1921+
"target": "es5",
1922+
"noImplicitAny": true,
1923+
"sourceMap": false,
1924+
"lib": [
1925+
"es5"
1926+
]
1927+
}
1928+
})
1929+
};
1930+
const config2 = {
1931+
path: config1.path,
1932+
content: JSON.stringify(
1933+
{
1934+
"compilerOptions": {
1935+
"module": "commonjs",
1936+
"target": "es5",
1937+
"noImplicitAny": true,
1938+
"sourceMap": false,
1939+
"lib": [
1940+
"es5",
1941+
"es2015.promise"
1942+
]
1943+
}
1944+
})
1945+
};
1946+
const host = createServerHost([libES5, libES2015Promise, app, config1], { executingFilePath: "/compiler/tsc.js" });
1947+
const projectService = createProjectService(host);
1948+
projectService.openClientFile(app.path);
1949+
1950+
projectService.checkNumberOfProjects({ configuredProjects: 1 });
1951+
checkProjectActualFiles(projectService.configuredProjects[0], [libES5.path, app.path]);
1952+
1953+
host.reloadFS([libES5, libES2015Promise, app, config2]);
1954+
host.triggerFileWatcherCallback(config1.path);
1955+
1956+
projectService.checkNumberOfProjects({ configuredProjects: 1 });
1957+
checkProjectActualFiles(projectService.configuredProjects[0], [libES5.path, libES2015Promise.path, app.path]);
1958+
});
19011959
});
19021960

19031961
describe("prefer typings to js", () => {

0 commit comments

Comments
 (0)