Skip to content

Turn on noEmit for inferred / external projects without ts files #11968

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/server/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,15 @@ namespace ts.server {
// - newProgram is different from the old program and structure of the old program was not reused.
if (!oldProgram || (this.program !== oldProgram && !oldProgram.structureIsReused)) {
hasChanges = true;

const options = this.getCompilerOptions();
if ((this.projectKind === ProjectKind.Inferred || this.projectKind === ProjectKind.External) && !options.noEmit && allFilesAreJsOrDts(this)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updateGraphWorker doesn't seem to be the right place to be setting default options. Isn't there some other place we typically do this? Chat with Vlad/Mohamed about where setting this would best live (if you haven't already - in which case ignore me!).

options.noEmit = true;
this.lsHost.setCompilationSettings(options);
// need to get a new program as the compiler option changed.
this.program = this.languageService.getProgram();
}

if (oldProgram) {
for (const f of oldProgram.getSourceFiles()) {
if (this.program.getSourceFileByPath(f.path)) {
Expand Down