fix(language-service): parse extended i18n forms

This commit is contained in:
Chuck Jazdzewski 2017-04-04 10:31:01 -07:00 committed by Alex Rickabaugh
parent fe0d02fc47
commit bde9771991
2 changed files with 24 additions and 2 deletions

View File

@ -110,7 +110,7 @@ class LanguageServiceImpl implements LanguageService {
const config = new CompilerConfig();
const parser = new TemplateParser(
config, expressionParser, new DomElementSchemaRegistry(), htmlParser, null, []);
const htmlResult = htmlParser.parse(template.source, '');
const htmlResult = htmlParser.parse(template.source, '', true);
const analyzedModules = this.host.getAnalyzedModules();
let errors: Diagnostic[] = undefined;
let ngModule = analyzedModules.ngModuleByPipeOrDirective.get(template.type);

View File

@ -236,6 +236,28 @@ describe('diagnostics', () => {
fileName => onlyModuleDiagnostics(ngService.getDiagnostics(fileName)));
});
// Issue #15625
it('should not report errors for localization syntax', () => {
addCode(
`
@Component({
selector: 'my-component',
template: \`
<div>
{fieldCount, plural, =0 {no fields} =1 {1 field} other {{{fieldCount}} fields}}
</div>
\`
})
export class MyComponent {
fieldCount: number;
}
`,
fileName => {
const diagnostics = ngService.getDiagnostics(fileName);
onlyModuleDiagnostics(diagnostics);
});
});
function addCode(code: string, cb: (fileName: string, content?: string) => void) {
const fileName = '/app/app.component.ts';
const originalContent = mockHost.getFileContent(fileName);
@ -255,7 +277,7 @@ describe('diagnostics', () => {
if (diagnostics.length > 1) {
for (const diagnostic of diagnostics) {
if (diagnostic.message.indexOf('MyComponent') >= 0) continue;
console.error(`(${diagnostic.span.start}:${diagnostic.span.end}): ${diagnostic.message}`);
fail(`(${diagnostic.span.start}:${diagnostic.span.end}): ${diagnostic.message}`);
}
return;
}