diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 5cc3bf47f8..1f82f2cbe0 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -170,6 +170,7 @@ namespace ts.server { readonly openFiles: ScriptInfo[] = []; private compilerOptionsForInferredProjects: CompilerOptions; + private compileOnSaveForInferredProjects: boolean; private readonly directoryWatchers: DirectoryWatchers; private readonly throttledOperations: ThrottledOperations; @@ -228,10 +229,12 @@ namespace ts.server { } } - setCompilerOptionsForInferredProjects(compilerOptions: CompilerOptions): void { - this.compilerOptionsForInferredProjects = compilerOptions; + setCompilerOptionsForInferredProjects(projectCompilerOptions: protocol.ExternalProjectCompilerOptions): void { + this.compilerOptionsForInferredProjects = projectCompilerOptions; + this.compileOnSaveForInferredProjects = projectCompilerOptions.compileOnSave; for (const proj of this.inferredProjects) { - proj.setCompilerOptions(compilerOptions); + proj.setCompilerOptions(projectCompilerOptions); + proj.compileOnSaveEnabled = projectCompilerOptions.compileOnSave; } this.updateProjectGraphs(this.inferredProjects); } @@ -920,7 +923,7 @@ namespace ts.server { const useExistingProject = this.useSingleInferredProject && this.inferredProjects.length; const project = useExistingProject ? this.inferredProjects[0] - : new InferredProject(this, this.documentRegistry, /*languageServiceEnabled*/ true, this.compilerOptionsForInferredProjects, /*compileOnSaveEnabled*/ false); + : new InferredProject(this, this.documentRegistry, /*languageServiceEnabled*/ true, this.compilerOptionsForInferredProjects, /*compileOnSaveEnabled*/ this.compileOnSaveForInferredProjects); project.addRoot(root); diff --git a/src/server/protocol.d.ts b/src/server/protocol.d.ts index 8d88c761ba..76e01fa1b2 100644 --- a/src/server/protocol.d.ts +++ b/src/server/protocol.d.ts @@ -709,7 +709,7 @@ declare namespace ts.server.protocol { } export interface SetCompilerOptionsForInferredProjectsArgs { - options: CompilerOptions; + options: ExternalProjectCompilerOptions; } export interface SetCompilerOptionsForInferredProjectsRequest extends Request {