fix(language-service): Do not produce diagnostics if metadata for NgModule not found (#34113)
The language service incorrectly reports an error if it fails to find NgModule metadata for a particular Component / Directive. In many cases, the use case is legit, particularly in test. This commit removes such diagnostic message and cleans up the interface for `TypeScriptHost.getTemplateAst()`. PR closes https://github.com/angular/vscode-ng-language-service/issues/463 PR Close #34113
This commit is contained in:

committed by
Miško Hevery

parent
c16a79df5c
commit
39722df41e
@ -8,7 +8,6 @@
|
||||
|
||||
import * as tss from 'typescript/lib/tsserverlibrary';
|
||||
|
||||
import {isAstResult} from './common';
|
||||
import {getTemplateCompletions} from './completions';
|
||||
import {getDefinitionAndBoundSpan, getTsDefinitionAndBoundSpan} from './definitions';
|
||||
import {getDeclarationDiagnostics, getTemplateDiagnostics, ngDiagnosticToTsDiagnostic, uniqueBySpan} from './diagnostics';
|
||||
@ -34,11 +33,9 @@ class LanguageServiceImpl implements LanguageService {
|
||||
const templates = this.host.getTemplates(fileName);
|
||||
|
||||
for (const template of templates) {
|
||||
const astOrDiagnostic = this.host.getTemplateAst(template);
|
||||
if (isAstResult(astOrDiagnostic)) {
|
||||
results.push(...getTemplateDiagnostics(astOrDiagnostic));
|
||||
} else {
|
||||
results.push(astOrDiagnostic);
|
||||
const ast = this.host.getTemplateAst(template);
|
||||
if (ast) {
|
||||
results.push(...getTemplateDiagnostics(ast));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user