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;
|
getTcb(fileName: string, position: number): GetTcbResponse|undefined;
|
||||||
getComponentLocationsForTemplate(fileName: string): GetComponentLocationsForTemplateResponse;
|
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 {
|
getTcb(fileName: string, position: number): GetTcbResponse|undefined {
|
||||||
return this.withCompiler<GetTcbResponse>(compiler => {
|
return this.withCompiler<GetTcbResponse|undefined>(compiler => {
|
||||||
const templateInfo = getTemplateInfoAtPosition(fileName, position, compiler);
|
const templateInfo = getTemplateInfoAtPosition(fileName, position, compiler);
|
||||||
if (templateInfo === undefined) {
|
if (templateInfo === undefined) {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
@ -130,7 +130,7 @@ export function create(info: ts.server.PluginCreateInfo): NgLanguageService {
|
|||||||
return diagnostics;
|
return diagnostics;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTcb(fileName: string, position: number): GetTcbResponse {
|
function getTcb(fileName: string, position: number): GetTcbResponse|undefined {
|
||||||
return ngLS.getTcb(fileName, position);
|
return ngLS.getTcb(fileName, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user