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
@ -829,4 +829,20 @@ describe('diagnostics', () => {
|
||||
expect(content.substring(start !, start ! + length !)).toBe(`line${i}`);
|
||||
}
|
||||
});
|
||||
|
||||
it('should not produce diagnostics for non-exported directives', () => {
|
||||
const fileName = '/app/test.component.ts';
|
||||
mockHost.addScript(fileName, `
|
||||
import {Component} from '@angular/core';
|
||||
|
||||
@Component({
|
||||
template: '<test-comp></test-comp>'
|
||||
})
|
||||
class TestHostComponent {}
|
||||
`);
|
||||
const tsDiags = tsLS.getSemanticDiagnostics(fileName);
|
||||
expect(tsDiags).toEqual([]);
|
||||
const ngDiags = ngLS.getDiagnostics(fileName);
|
||||
expect(ngDiags).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user