From 1fbe6848345d2707bcde727e067267aa80ec88da Mon Sep 17 00:00:00 2001 From: Mine Starks Date: Thu, 30 Nov 2017 09:12:09 -0800 Subject: [PATCH] compileOnSaveAffectedFileList shouldn't return any files for noEmit projects --- src/harness/unittests/compileOnSave.ts | 18 ++++++++++++++++++ src/server/session.ts | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/harness/unittests/compileOnSave.ts b/src/harness/unittests/compileOnSave.ts index 7ef3e2aa1a..a64d7bdd2a 100644 --- a/src/harness/unittests/compileOnSave.ts +++ b/src/harness/unittests/compileOnSave.ts @@ -304,6 +304,24 @@ namespace ts.projectSystem { sendAffectedFileRequestAndCheckResult(session, moduleFile1FileListRequest, []); }); + it("should return empty array if noEmit is set", () => { + configFile = { + path: "/a/b/tsconfig.json", + content: `{ + "compileOnSave": true, + "compilerOptions": { + "noEmit": true + } + }` + }; + + const host = createServerHost([moduleFile1, file1Consumer1, file1Consumer2, configFile, libFile]); + const typingsInstaller = createTestTypingsInstaller(host); + const session = createSession(host, typingsInstaller); + openFilesForSession([moduleFile1], session); + sendAffectedFileRequestAndCheckResult(session, moduleFile1FileListRequest, []); + }); + it("should save when compileOnSave is enabled in base tsconfig.json", () => { configFile = { path: "/a/b/tsconfig.json", diff --git a/src/server/session.ts b/src/server/session.ts index 309a6aef0c..d3e44573ec 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -1245,7 +1245,7 @@ namespace ts.server { // if specified a project, we only return affected file list in this project const projectsToSearch = args.projectFileName ? [this.projectService.findProject(args.projectFileName)] : info.containingProjects; for (const project of projectsToSearch) { - if (project.compileOnSaveEnabled && project.languageServiceEnabled) { + if (project.compileOnSaveEnabled && project.languageServiceEnabled && !project.getCompilationSettings().noEmit) { result.push({ projectFileName: project.getProjectName(), fileNames: project.getCompileOnSaveAffectedFileList(info),