Skip to content

Commit fe0d02f

Browse files
chuckjazalxhub
authored andcommitted
fix(language-service): initialize static reflector correctly
Fixes #15768
1 parent 7b005aa commit fe0d02f

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

‎packages/language-service/src/typescript_host.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {AotSummaryResolver, CompileDirectiveMetadata, CompileMetadataResolver, CompilerConfig, DEFAULT_INTERPOLATION_CONFIG, DirectiveNormalizer, DirectiveResolver, DomElementSchemaRegistry, HtmlParser, InterpolationConfig, NgAnalyzedModules, NgModuleResolver, ParseTreeResult, Parser, PipeResolver, ResourceLoader, StaticReflector, StaticSymbol, StaticSymbolCache, StaticSymbolResolver, SummaryResolver, UrlResolver, analyzeNgModules, componentModuleUrl, createOfflineCompileUrlResolver, extractProgramSymbols} from '@angular/compiler';
9+
import {AotSummaryResolver, CompileDirectiveMetadata, CompileMetadataResolver, CompilerConfig, DEFAULT_INTERPOLATION_CONFIG, DirectiveNormalizer, DirectiveResolver, DomElementSchemaRegistry, HtmlParser, InterpolationConfig, NgAnalyzedModules, NgModuleResolver, ParseTreeResult, Parser, PipeResolver, ResourceLoader, StaticAndDynamicReflectionCapabilities, StaticReflector, StaticSymbol, StaticSymbolCache, StaticSymbolResolver, SummaryResolver, UrlResolver, analyzeNgModules, componentModuleUrl, createOfflineCompileUrlResolver, extractProgramSymbols} from '@angular/compiler';
1010
import {Type, ViewEncapsulation, ɵConsole as Console} from '@angular/core';
1111
import * as fs from 'fs';
1212
import * as path from 'path';
@@ -428,6 +428,7 @@ export class TypeScriptServiceHost implements LanguageServiceHost {
428428
const ssr = this.staticSymbolResolver;
429429
result = this._reflector = new StaticReflector(
430430
this._summaryResolver, ssr, [], [], (e, filePath) => this.collectError(e, filePath));
431+
StaticAndDynamicReflectionCapabilities.install(result);
431432
}
432433
return result;
433434
}

‎packages/language-service/test/diagnostics_spec.ts‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ describe('diagnostics', () => {
201201
expect(diagnostic).toEqual([]);
202202
});
203203

204-
205204
it('should report an error for invalid providers', () => {
206205
addCode(
207206
`
@@ -220,6 +219,23 @@ describe('diagnostics', () => {
220219
});
221220
});
222221

222+
// Issue #15768
223+
it('should be able to parse a template reference', () => {
224+
addCode(
225+
`
226+
@Component({
227+
selector: 'my-component',
228+
template: \`
229+
<div *ngIf="comps | async; let comps; else loading">
230+
</div>
231+
<ng-template #loading>Loading comps...</ng-template>
232+
\`
233+
})
234+
export class MyComponent {}
235+
`,
236+
fileName => onlyModuleDiagnostics(ngService.getDiagnostics(fileName)));
237+
});
238+
223239
function addCode(code: string, cb: (fileName: string, content?: string) => void) {
224240
const fileName = '/app/app.component.ts';
225241
const originalContent = mockHost.getFileContent(fileName);

0 commit comments

Comments
 (0)