From a84f7eec3b5852c79f569bc0abe76a98c570ff8b Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Mon, 7 Nov 2016 14:57:51 -0800 Subject: [PATCH] property handle missing config files in external projects --- .../unittests/tsserverProjectSystem.ts | 21 +++++++++++++++++++ src/server/editorServices.ts | 4 +++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index ee6139b1215c6..d37d61255a6d8 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -2222,6 +2222,27 @@ namespace ts.projectSystem { assert.equal(diags.length, 0); }); + it("should property handle missing config files", () => { + const f1 = { + path: "/a/b/app.ts", + content: "let x = 1" + }; + const config = { + path: "/a/b/tsconfig.json", + content: "{}" + }; + const projectName = "project1"; + const host = createServerHost([f1]); + const projectService = createProjectService(host); + projectService.openExternalProject({ rootFiles: toExternalFiles([f1.path, config.path]), options: {}, projectFileName: projectName }); + + // should have one external project since config file is missing + projectService.checkNumberOfProjects({ externalProjects: 1 }); + + host.reloadFS([f1, config]); + projectService.openExternalProject({ rootFiles: toExternalFiles([f1.path, config.path]), options: {}, projectFileName: projectName }); + projectService.checkNumberOfProjects({ configuredProjects: 1 }); + }); }); describe("add the missing module file for inferred project", () => { diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index bf760106b7435..269eea064647d 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -1288,7 +1288,9 @@ namespace ts.server { for (const file of proj.rootFiles) { const normalized = toNormalizedPath(file.fileName); if (getBaseFileName(normalized) === "tsconfig.json") { - (tsConfigFiles || (tsConfigFiles = [])).push(normalized); + if (this.host.fileExists(normalized)) { + (tsConfigFiles || (tsConfigFiles = [])).push(normalized); + } } else { rootFiles.push(file);