Skip to content

Commit

Permalink
fix: ensure project language service is the Angular LS
Browse files Browse the repository at this point in the history
Add check to ensure the returned language service for the project is the Angular
Language Service. This removes the need for a type assertion and also prevents
the native TS LS from taking the place of ours if there is an issue with the
plugin registration (which would result in duplicate results in TS files).

Fixes angular#1110.
  • Loading branch information
atscott committed Feb 17, 2021
1 parent 2a7e42c commit eb14713
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion server/src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -708,8 +708,12 @@ export class Session {
this.logger.info(`Failed to get language service for closed project ${project.projectName}.`);
return undefined;
}
const languageService = project.getLanguageService();
if (!isNgLs(languageService)) {
return undefined;
}
return {
languageService: project.getLanguageService() as NgLanguageService,
languageService,
scriptInfo,
};
}
Expand Down Expand Up @@ -937,3 +941,7 @@ function toArray<T>(it: ts.Iterator<T>): T[] {
}
return results;
}

function isNgLs(ls: ts.LanguageService|NgLanguageService): ls is NgLanguageService {
return 'getTcb' in ls;
}

0 comments on commit eb14713

Please sign in to comment.