fix(language-service): initialize static reflector correctly

Fixes #15768
This commit is contained in:
Chuck Jazdzewski 2017-04-04 11:37:06 -07:00 committed by Alex Rickabaugh
parent 7b005aadc1
commit fe0d02fc47
2 changed files with 19 additions and 2 deletions

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
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';
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';
import {Type, ViewEncapsulation, ɵConsole as Console} from '@angular/core';
import * as fs from 'fs';
import * as path from 'path';
@ -428,6 +428,7 @@ export class TypeScriptServiceHost implements LanguageServiceHost {
const ssr = this.staticSymbolResolver;
result = this._reflector = new StaticReflector(
this._summaryResolver, ssr, [], [], (e, filePath) => this.collectError(e, filePath));
StaticAndDynamicReflectionCapabilities.install(result);
}
return result;
}

View File

@ -201,7 +201,6 @@ describe('diagnostics', () => {
expect(diagnostic).toEqual([]);
});
it('should report an error for invalid providers', () => {
addCode(
`
@ -220,6 +219,23 @@ describe('diagnostics', () => {
});
});
// Issue #15768
it('should be able to parse a template reference', () => {
addCode(
`
@Component({
selector: 'my-component',
template: \`
<div *ngIf="comps | async; let comps; else loading">
</div>
<ng-template #loading>Loading comps...</ng-template>
\`
})
export class MyComponent {}
`,
fileName => onlyModuleDiagnostics(ngService.getDiagnostics(fileName)));
});
function addCode(code: string, cb: (fileName: string, content?: string) => void) {
const fileName = '/app/app.component.ts';
const originalContent = mockHost.getFileContent(fileName);