From 779f67777d127d1dd707387a8b05f50ceffb9294 Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Thu, 20 Aug 2026 11:42:51 -0700 Subject: [PATCH] =?UTF-8?q?refactor(core):=20=20widen=20=C9=B5=C9=B5classP?= =?UTF-8?q?rop=20value=20parameter=20type=20to=20any?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When Angular type-checks host bindings and template class bindings (`[class.foo]="expr"`), the Type Check Block (TCB) emits the binding as a standalone expression statement (e.g. `(expr);`). This verifies that the expression itself is syntactically and semantically valid (e.g. properties exist on the component instance), but does not constrain the expression to `boolean` because Angular evaluates class bindings using standard JavaScript truthiness. In classic `ngtsc`, the runtime Ivy instructions (`ɵɵdefineComponent`) were generated only during the JS emit phase, after TypeScript type-checking had completed. Thus, `tsc` never validated the arguments passed to `ɵɵclassProp`. Under standalone commpilation, Ivy definitions are generated directly into the TypeScript AST and type-checked by `tsc`. This causes `tsc` to check the emitted `ɵɵclassProp('foo', expr)` call against the instruction's declared signature. Because `ɵɵclassProp` was strictly typed as `boolean | undefined | null`, any valid truthy non-boolean expression (e.g., `1`, `items.length`, or non-empty strings) produces a `TS2345` compiler error. At runtime, `ɵɵclassProp` delegates to `checkStylingProperty`, which evaluates the value via truthiness (`!!value`). Widening the parameter type to `any` aligns the instruction's type signature with Angular's binding semantics and prevents type-checking failures during in-place compilation. --- packages/core/src/render3/instructions/styling.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/core/src/render3/instructions/styling.ts b/packages/core/src/render3/instructions/styling.ts index 383d38c9526..fd7a74be347 100644 --- a/packages/core/src/render3/instructions/styling.ts +++ b/packages/core/src/render3/instructions/styling.ts @@ -104,10 +104,7 @@ export function ɵɵstyleProp( * * @codeGenApi */ -export function ɵɵclassProp( - className: string, - value: boolean | undefined | null, -): typeof ɵɵclassProp { +export function ɵɵclassProp(className: string, value: any): typeof ɵɵclassProp { checkStylingProperty(className, value, null, true); return ɵɵclassProp; }