Skip to content

Commit ced5e24

Browse files
authored
fix(server): Do not disable language service for solution style root tsconfig (#1972)
Do not disable language service for project if it has project references. Even though we couldn't find angular/core for this parent tsconfig, it might exist in the referenced projects. Disabling the language service for this root project will clean up the program for the project. microsoft/TypeScript@3c4c060#diff-fad6af6557c1406192e30af30e0113a5eb327d60f9e2588bdce6667d619ebd04R973-R983 We need to keep this language service and program enabled because referenced projects don't load until we open a client file for that project. fixes #1959
1 parent 1dd740a commit ced5e24

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

server/src/session.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,8 @@ export class Session {
456456
if (!project.languageServiceEnabled) {
457457
return;
458458
}
459-
project.disableLanguageService(
460-
`Disabling language service for ${project.getProjectName()} because ${reason}.`);
459+
this.info(`Disabling language service for ${project.getProjectName()} because ${reason}.`);
460+
project.disableLanguageService();
461461
}
462462

463463

@@ -523,6 +523,18 @@ export class Session {
523523
const angularCore = this.findAngularCore(project);
524524
if (angularCore) {
525525
this.enableLanguageServiceForProject(project);
526+
} else if (project.getProjectReferences()?.length) {
527+
// Do not disable language service for project if it has project references. Even though
528+
// we couldn't find angular/core for this parent tsconfig, it might exist in the
529+
// referenced projects. Disabling the language service for this root project will clean up
530+
// the program for the project.
531+
// https://github.com/microsoft/TypeScript/commit/3c4c060dff2b0292d3a4d88ba0627b7657d67e7f#diff-fad6af6557c1406192e30af30e0113a5eb327d60f9e2588bdce6667d619ebd04R973-R983
532+
// We need to keep this language service and program enabled because referenced projects
533+
// don't load until we open a client file for that project.
534+
this.info(
535+
`@angular/core could not be found for project ${
536+
project.getProjectName()} but it has references that might.` +
537+
` The Angular language service will remain enabled for this project.`);
526538
} else {
527539
this.disableLanguageServiceForProject(
528540
project, `project is not an Angular project ('@angular/core' could not be found)`);

0 commit comments

Comments
 (0)