Skip to content

Commit c0f187a

Browse files
author
Ben Lichtman
committed
Allow compile on save with decorator emit
1 parent 0cab79f commit c0f187a

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/server/session.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,6 +1599,10 @@ namespace ts.server {
15991599
return emptyArray;
16001600
}
16011601

1602+
function dtsChangeCanAffectEmit(compilationSettings: CompilerOptions) {
1603+
return getEmitDeclarations(compilationSettings) || !!compilationSettings.emitDecoratorMetadata;
1604+
}
1605+
16021606
return combineProjectOutput(
16031607
info,
16041608
path => this.projectService.getScriptInfoForPath(path)!,
@@ -1610,8 +1614,8 @@ namespace ts.server {
16101614

16111615
const compilationSettings = project.getCompilationSettings();
16121616

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
1617+
if (!!compilationSettings.noEmit || fileExtensionIs(info.fileName, Extension.Dts) && !dtsChangeCanAffectEmit(compilationSettings)) {
1618+
// avoid triggering emit when a change is made in a .d.ts when declaration emit and decorator metadata emit are disabled
16151619
return undefined;
16161620
}
16171621

src/testRunner/unittests/tsserver/compileOnSave.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,15 @@ namespace ts.projectSystem {
598598
/*expectDTSEmit*/ true
599599
);
600600
});
601+
602+
it("should return results if change is made in a global declaration file with decorator emit enabled", () => {
603+
testDTS(
604+
/*dtsFileContents*/ "declare const x: string;",
605+
/*tsFileContents*/ "var y = 1;",
606+
/*opts*/ { experimentalDecorators: true, emitDecoratorMetadata: true },
607+
/*expectDTSEmit*/ true
608+
);
609+
});
601610
});
602611

603612
describe("tsserverProjectSystem emit with outFile or out setting", () => {

0 commit comments

Comments
 (0)