Skip to content

Commit

Permalink
fix(language-service): parse extended i18n forms
Browse files Browse the repository at this point in the history
  • Loading branch information
chuckjaz authored and alxhub committed Apr 4, 2017
1 parent fe0d02f commit bde9771
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/language-service/src/language_service.ts
Expand Up @@ -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);
Expand Down
24 changes: 23 additions & 1 deletion packages/language-service/test/diagnostics_spec.ts
Expand Up @@ -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);
Expand All @@ -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;
}
Expand Down

0 comments on commit bde9771

Please sign in to comment.