diff --git a/packages/compiler-cli/src/ngtsc/typecheck/extended/api/api.ts b/packages/compiler-cli/src/ngtsc/typecheck/extended/api/api.ts index 31149c33846ed..3c27bb3adcb45 100644 --- a/packages/compiler-cli/src/ngtsc/typecheck/extended/api/api.ts +++ b/packages/compiler-cli/src/ngtsc/typecheck/extended/api/api.ts @@ -228,7 +228,10 @@ class TemplateVisitor 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); diff --git a/packages/compiler-cli/src/ngtsc/typecheck/extended/test/checks/unused_let_declaration/unused_let_declaration_spec.ts b/packages/compiler-cli/src/ngtsc/typecheck/extended/test/checks/unused_let_declaration/unused_let_declaration_spec.ts index 3afced6bf38a9..209945e915ddc 100644 --- a/packages/compiler-cli/src/ngtsc/typecheck/extended/test/checks/unused_let_declaration/unused_let_declaration_spec.ts +++ b/packages/compiler-cli/src/ngtsc/typecheck/extended/test/checks/unused_let_declaration/unused_let_declaration_spec.ts @@ -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; +

{value, select, 1 {one} 2 {two} other {other}}

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