Avoid compile on save for declaration files

This commit is contained in:
Ben Lichtman 2019-08-02 15:53:54 -07:00
parent 9243415ead
commit 5233bcc064

View File

@ -1604,15 +1604,22 @@ namespace ts.server {
path => this.projectService.getScriptInfoForPath(path)!,
projects,
(project, info) => {
let result: protocol.CompileOnSaveAffectedFileListSingleProject | undefined;
if (project.compileOnSaveEnabled && project.languageServiceEnabled && !project.isOrphan() && !project.getCompilationSettings().noEmit) {
result = {
projectFileName: project.getProjectName(),
fileNames: project.getCompileOnSaveAffectedFileList(info),
projectUsesOutFile: !!project.getCompilationSettings().outFile || !!project.getCompilationSettings().out
};
if (!project.compileOnSaveEnabled || !project.languageServiceEnabled || project.isOrphan()) {
return undefined;
}
return result;
const compilationSettings = project.getCompilationSettings();
if (!!compilationSettings.noEmit || fileExtensionIs(info.fileName, Extension.Dts) && !getEmitDeclarations(compilationSettings)) {
// avoid triggering emit when a change is made in a .d.ts when declaration emit is disabled
return undefined;
}
return {
projectFileName: project.getProjectName(),
fileNames: project.getCompileOnSaveAffectedFileList(info),
projectUsesOutFile: !!compilationSettings.outFile || !!compilationSettings.out
};
}
);
}