Skip to content

Allow readonly array typings for the preprocessor - #70002

Open
alxhub wants to merge 2 commits into
angular:mainfrom
alxhub:type-safety-for-ngp
Open

Allow readonly array typings for the preprocessor#70002
alxhub wants to merge 2 commits into
angular:mainfrom
alxhub:type-safety-for-ngp

Conversation

@alxhub

@alxhub alxhub commented Jul 29, 2026

Copy link
Copy Markdown
Member

Adjust the Angular APIs in a few places to only require readonly arrays. This allows us to avoid a @ts-ignore in cases when the preprocessor needs to call these APIs.

@angular-robot angular-robot Bot added the area: core Issues related to the framework runtime label Jul 29, 2026
@ngbot ngbot Bot added this to the Backlog milestone Jul 29, 2026
@alxhub
alxhub force-pushed the type-safety-for-ngp branch 4 times, most recently from 6557911 to e3c8260 Compare July 29, 2026 23:11
@alxhub alxhub added the target: patch This PR is targeted for the next patch release label Jul 29, 2026
@mattrbeck

Copy link
Copy Markdown
Member

Is this good to merge?

alxhub added 2 commits August 4, 2026 15:59
When components pass  arrays or readonly tuples to decorator metadata fields (such as ), typechecking generated decorator reflection metadata causes a TS2322 type mismatch error because  previously only accepted mutable .

This change updates  to accept , allowing  arrays and readonly tuples to be assigned without TypeScript compilation errors.
When reflection metadata is emitted via setClassMetadata, passing readonly arrays or const tuples for the decorators parameter causes TypeScript type checking errors because setClassMetadata previously expected decorators to be a mutable any[] or null.

This change updates the setClassMetadata type signature to accept decorators as readonly any[] or null and casts the parameter internally when mutating the class metadata property.
@alxhub
alxhub force-pushed the type-safety-for-ngp branch from e3c8260 to e74d5e2 Compare August 4, 2026 16:00
@alxhub alxhub added action: merge The PR is ready for merge by the caretaker merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note labels Aug 4, 2026
@alxhub

alxhub commented Aug 4, 2026

Copy link
Copy Markdown
Member Author

Caretaker: presubmit is "green"

@thePunderWoman

Copy link
Copy Markdown
Contributor

This probably needs a rebase for the github actions scan to pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: core Issues related to the framework runtime merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants