From 13baa2d573bf78063ba4bf6580e505fa429c3eb8 Mon Sep 17 00:00:00 2001 From: Chuck Jazdzewski Date: Tue, 28 Mar 2017 09:37:24 -0700 Subject: [PATCH] fix(language-service): be resilient to invalidate ordering (#15470) Fixes #15466 --- packages/language-service/src/typescript_host.ts | 2 +- packages/language-service/test/diagnostics_spec.ts | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/language-service/src/typescript_host.ts b/packages/language-service/src/typescript_host.ts index 59facc4b0c70c1..28197c24f51fdb 100644 --- a/packages/language-service/src/typescript_host.ts +++ b/packages/language-service/src/typescript_host.ts @@ -492,7 +492,7 @@ export class TypeScriptServiceHost implements LanguageServiceHost { const type = this.checker.getTypeAtLocation(target); if (type) { const staticSymbol = - this._reflector.getStaticSymbol(sourceFile.fileName, classDeclaration.name.text); + this.reflector.getStaticSymbol(sourceFile.fileName, classDeclaration.name.text); try { if (this.resolver.isDirective(staticSymbol as any)) { const {metadata} = diff --git a/packages/language-service/test/diagnostics_spec.ts b/packages/language-service/test/diagnostics_spec.ts index c0df4daf63102f..7a4dc1147f51fe 100644 --- a/packages/language-service/test/diagnostics_spec.ts +++ b/packages/language-service/test/diagnostics_spec.ts @@ -52,6 +52,15 @@ describe('diagnostics', () => { 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', () => { it('should accept an event', () => { accept('
Click me!
'); });