Skip to content

Commit

Permalink
fix(compiler-cli): extended diagnostics not validating ICUs (angular#…
Browse files Browse the repository at this point in the history
…57845)

The visitor that all extended diagnostics are based on hadn't implemented the `visitIcu` method which meant that it wasn't detecting any code inside of them.

Fixes angular#57838.

PR Close angular#57845
  • Loading branch information
crisbeto authored and pkozlowski-opensource committed Sep 18, 2024
1 parent d0a71a3 commit f611faa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,10 @@ class TemplateVisitor<Code extends ErrorCode>
visitBoundText(text: TmplAstBoundText): void {
this.visitAst(text.value);
}
visitIcu(icu: TmplAstIcu): void {}
visitIcu(icu: TmplAstIcu): void {
Object.keys(icu.vars).forEach((key) => this.visit(icu.vars[key]));
Object.keys(icu.placeholders).forEach((key) => this.visit(icu.placeholders[key]));
}

visitDeferredBlock(deferred: TmplAstDeferredBlock): void {
deferred.visitAll(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,14 @@ runInEachFileSystem(() => {

expect(diags.length).toBe(0);
});

it('should not report a @let declaration that is only used in an ICU', () => {
const diags = diagnose(`
@let value = 1;
<h1 i18n>{value, select, 1 {one} 2 {two} other {other}}</h1>
`);

expect(diags.length).toBe(0);
});
});
});

0 comments on commit f611faa

Please sign in to comment.