Skip to content

Commit e685ed8

Browse files
crisbetopkozlowski-opensource
authored andcommitted
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
1 parent 7fdb479 commit e685ed8

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

packages/compiler-cli/src/ngtsc/typecheck/extended/api/api.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,10 @@ class TemplateVisitor<Code extends ErrorCode>
228228
visitBoundText(text: TmplAstBoundText): void {
229229
this.visitAst(text.value);
230230
}
231-
visitIcu(icu: TmplAstIcu): void {}
231+
visitIcu(icu: TmplAstIcu): void {
232+
Object.keys(icu.vars).forEach((key) => this.visit(icu.vars[key]));
233+
Object.keys(icu.placeholders).forEach((key) => this.visit(icu.placeholders[key]));
234+
}
232235

233236
visitDeferredBlock(deferred: TmplAstDeferredBlock): void {
234237
deferred.visitAll(this);

packages/compiler-cli/src/ngtsc/typecheck/extended/test/checks/unused_let_declaration/unused_let_declaration_spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,14 @@ runInEachFileSystem(() => {
108108

109109
expect(diags.length).toBe(0);
110110
});
111+
112+
it('should not report a @let declaration that is only used in an ICU', () => {
113+
const diags = diagnose(`
114+
@let value = 1;
115+
<h1 i18n>{value, select, 1 {one} 2 {two} other {other}}</h1>
116+
`);
117+
118+
expect(diags.length).toBe(0);
119+
});
111120
});
112121
});

0 commit comments

Comments
 (0)