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:
Keen Yee Liau
2019-11-27 15:46:58 -08:00
committed by Miško Hevery
parent c16a79df5c
commit 39722df41e
6 changed files with 53 additions and 68 deletions

View File

@ -8,7 +8,6 @@
import * as ts from 'typescript';
import {isAstResult} from './common';
import {createGlobalSymbolTable} from './global_symbols';
import * as ng from './types';
import {TypeScriptServiceHost} from './typescript_host';
@ -73,7 +72,7 @@ abstract class BaseTemplate implements ng.TemplateSource {
// TODO: There is circular dependency here between TemplateSource and
// TypeScriptHost. Consider refactoring the code to break this cycle.
const ast = this.host.getTemplateAst(this);
const pipes = isAstResult(ast) ? ast.pipes : [];
const pipes = (ast && ast.pipes) || [];
return getPipesTable(sourceFile, program, typeChecker, pipes);
});
}