fix(compiler-cli): extended diagnostics not validating ICUs (#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 #57838.

PR Close #57845
This commit is contained in:
Kristiyan Kostadinov 2024-09-17 09:46:35 +02:00 committed by Pawel Kozlowski
parent d0a71a33b1
commit f611faadfe
2 changed files with 13 additions and 1 deletions

View file

@ -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);

View file

@ -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);
});
});
});