Skip to content

Commit 5233bcc

Browse files
author
Ben Lichtman
committed
Avoid compile on save for declaration files
1 parent 9243415 commit 5233bcc

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/server/session.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,15 +1604,22 @@ namespace ts.server {
16041604
path => this.projectService.getScriptInfoForPath(path)!,
16051605
projects,
16061606
(project, info) => {
1607-
let result: protocol.CompileOnSaveAffectedFileListSingleProject | undefined;
1608-
if (project.compileOnSaveEnabled && project.languageServiceEnabled && !project.isOrphan() && !project.getCompilationSettings().noEmit) {
1609-
result = {
1610-
projectFileName: project.getProjectName(),
1611-
fileNames: project.getCompileOnSaveAffectedFileList(info),
1612-
projectUsesOutFile: !!project.getCompilationSettings().outFile || !!project.getCompilationSettings().out
1613-
};
1607+
if (!project.compileOnSaveEnabled || !project.languageServiceEnabled || project.isOrphan()) {
1608+
return undefined;
1609+
}
1610+
1611+
const compilationSettings = project.getCompilationSettings();
1612+
1613+
if (!!compilationSettings.noEmit || fileExtensionIs(info.fileName, Extension.Dts) && !getEmitDeclarations(compilationSettings)) {
1614+
// avoid triggering emit when a change is made in a .d.ts when declaration emit is disabled
1615+
return undefined;
16141616
}
1615-
return result;
1617+
1618+
return {
1619+
projectFileName: project.getProjectName(),
1620+
fileNames: project.getCompileOnSaveAffectedFileList(info),
1621+
projectUsesOutFile: !!compilationSettings.outFile || !!compilationSettings.out
1622+
};
16161623
}
16171624
);
16181625
}

0 commit comments

Comments
 (0)