Skip to content

Commit 191b45e

Browse files
Zhengbo LiZhengbo Li
Zhengbo Li
authored and
Zhengbo Li
committed
Turn on noEmit for inferred / external projects without ts files
1 parent ad9c148 commit 191b45e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/server/project.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,15 @@ namespace ts.server {
471471
// - newProgram is different from the old program and structure of the old program was not reused.
472472
if (!oldProgram || (this.program !== oldProgram && !oldProgram.structureIsReused)) {
473473
hasChanges = true;
474+
475+
const options = this.getCompilerOptions();
476+
if ((this.projectKind === ProjectKind.Inferred || this.projectKind === ProjectKind.External) && !options.noEmit && allFilesAreJsOrDts(this)) {
477+
options.noEmit = true;
478+
this.lsHost.setCompilationSettings(options);
479+
// need to get a new program as the compiler option changed.
480+
this.program = this.languageService.getProgram();
481+
}
482+
474483
if (oldProgram) {
475484
for (const f of oldProgram.getSourceFiles()) {
476485
if (this.program.getSourceFileByPath(f.path)) {

0 commit comments

Comments
 (0)