refactor(language-service): add type guard for NgLanguageService (#40954)
Type guard should be colocated with the `NgLanguageService` interface, not in `@angular/vscode-ng-language-service`. PR Close #40954
This commit is contained in:
parent
3d8ac06e4b
commit
7101267923
|
@ -43,3 +43,8 @@ export interface NgLanguageService extends ts.LanguageService {
|
|||
getTcb(fileName: string, position: number): GetTcbResponse|undefined;
|
||||
getComponentLocationsForTemplate(fileName: string): GetComponentLocationsForTemplateResponse;
|
||||
}
|
||||
|
||||
export function isNgLanguageService(ls: ts.LanguageService|
|
||||
NgLanguageService): ls is NgLanguageService {
|
||||
return 'getTcb' in ls;
|
||||
}
|
||||
|
|
|
@ -247,8 +247,8 @@ export class LanguageService {
|
|||
});
|
||||
}
|
||||
|
||||
getTcb(fileName: string, position: number): GetTcbResponse {
|
||||
return this.withCompiler<GetTcbResponse>(compiler => {
|
||||
getTcb(fileName: string, position: number): GetTcbResponse|undefined {
|
||||
return this.withCompiler<GetTcbResponse|undefined>(compiler => {
|
||||
const templateInfo = getTemplateInfoAtPosition(fileName, position, compiler);
|
||||
if (templateInfo === undefined) {
|
||||
return undefined;
|
||||
|
@ -496,4 +496,4 @@ function findTightestNodeAtPosition(program: ts.Program, fileName: string, posit
|
|||
}
|
||||
|
||||
return findTightestNode(sourceFile, position);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@ export function create(info: ts.server.PluginCreateInfo): NgLanguageService {
|
|||
return diagnostics;
|
||||
}
|
||||
|
||||
function getTcb(fileName: string, position: number): GetTcbResponse {
|
||||
function getTcb(fileName: string, position: number): GetTcbResponse|undefined {
|
||||
return ngLS.getTcb(fileName, position);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue