Allow compile on save with decorator emit

This commit is contained in:
Ben Lichtman 2019-08-06 13:39:18 -07:00
parent 0cab79fc56
commit c0f187a4e8
2 changed files with 15 additions and 2 deletions

View File

@ -1599,6 +1599,10 @@ namespace ts.server {
return emptyArray;
}
function dtsChangeCanAffectEmit(compilationSettings: CompilerOptions) {
return getEmitDeclarations(compilationSettings) || !!compilationSettings.emitDecoratorMetadata;
}
return combineProjectOutput(
info,
path => this.projectService.getScriptInfoForPath(path)!,
@ -1610,8 +1614,8 @@ namespace ts.server {
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
if (!!compilationSettings.noEmit || fileExtensionIs(info.fileName, Extension.Dts) && !dtsChangeCanAffectEmit(compilationSettings)) {
// avoid triggering emit when a change is made in a .d.ts when declaration emit and decorator metadata emit are disabled
return undefined;
}

View File

@ -598,6 +598,15 @@ namespace ts.projectSystem {
/*expectDTSEmit*/ true
);
});
it("should return results if change is made in a global declaration file with decorator emit enabled", () => {
testDTS(
/*dtsFileContents*/ "declare const x: string;",
/*tsFileContents*/ "var y = 1;",
/*opts*/ { experimentalDecorators: true, emitDecoratorMetadata: true },
/*expectDTSEmit*/ true
);
});
});
describe("tsserverProjectSystem emit with outFile or out setting", () => {