fix(language-service): be resilient to invalidate ordering (#15470)

Fixes #15466
This commit is contained in:
Chuck Jazdzewski 2017-03-28 09:37:24 -07:00 committed by Victor Berchet
parent d05aa70c6b
commit a5c972aa8b
2 changed files with 10 additions and 1 deletions

View File

@ -492,7 +492,7 @@ export class TypeScriptServiceHost implements LanguageServiceHost {
const type = this.checker.getTypeAtLocation(target); const type = this.checker.getTypeAtLocation(target);
if (type) { if (type) {
const staticSymbol = const staticSymbol =
this._reflector.getStaticSymbol(sourceFile.fileName, classDeclaration.name.text); this.reflector.getStaticSymbol(sourceFile.fileName, classDeclaration.name.text);
try { try {
if (this.resolver.isDirective(staticSymbol as any)) { if (this.resolver.isDirective(staticSymbol as any)) {
const {metadata} = const {metadata} =

View File

@ -52,6 +52,15 @@ describe('diagnostics', () => {
includeDiagnostic(diagnostics(template), message, at, len); includeDiagnostic(diagnostics(template), message, at, len);
} }
describe('regression', () => {
it('should be able to return diagnostics if reflector gets invalidated', () => {
const fileName = '/app/main.ts';
ngService.getDiagnostics(fileName);
(ngHost as any)._reflector = null;
ngService.getDiagnostics(fileName);
});
});
describe('with $event', () => { describe('with $event', () => {
it('should accept an event', it('should accept an event',
() => { accept('<div (click)="myClick($event)">Click me!</div>'); }); () => { accept('<div (click)="myClick($event)">Click me!</div>'); });