Skip to content

Conversation

@crisbeto
Copy link
Member

Currently if TestBed.overrideComponent is used on a class that uses initializer APIs (e.g. input()), the initializer metadata will be wiped out, because overrideComponent re-compiles the class with the information set by setClassMetadata. setClassMetadata only captures decorated members at the moment.

These changes introduce some logic to capture the new initializer-based APIs in setClassMetadata as well.

Fixes #57944.

Reworks the logic that tracks the decorator metadata for members to do so using the output AST, rather than wrapping the TypeScript AST. This makes it easier to programmatically generate new members that weren't part of the TypeScript AST before.
@crisbeto crisbeto added action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release labels Sep 18, 2025
@angular-robot angular-robot bot added the area: compiler Issues related to `ngc`, Angular's template compiler label Sep 18, 2025
@ngbot ngbot bot added this to the Backlog milestone Sep 18, 2025
Adds the member decorators to the map of exposed compiler symbols.
@crisbeto crisbeto force-pushed the 61229/signals-set-class-metadata branch from 68d7ead to 41bb4f3 Compare September 18, 2025 10:49
@crisbeto crisbeto requested a review from devversion September 18, 2025 11:03
@crisbeto crisbeto marked this pull request as ready for review September 18, 2025 11:03
Copy link
Member

@devversion devversion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, non-blocking comments

* Returns a function that can be used to extract data for the `setClassMetadata`
* calls from undecorated directive class members.
*/
export function getDirectiveUndecoratedMetadataExtractor(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we could have built up this data synthetically afte all signal inputs, queries, model etc are known? Mostly my hope would be to avoid having to call these tryParseX methods again?

Did you also explore re-using some of the logic from the JIT transforms out of curiosity?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The annoying part here is that it's dealing with the output AST, rather than JS data types or the TS AST. Originally I wanted to reuse the metadata we already have on inputs, but it ended up being easier to hook into the output AST construction instead.

@crisbeto crisbeto force-pushed the 61229/signals-set-class-metadata branch 2 times, most recently from 02aa8b8 to e22d5c1 Compare September 18, 2025 16:58
Currently if `TestBed.overrideComponent` is used on a class that uses initializer APIs (e.g. `input()`), the initializer metadata will be wiped out, because `overrideComponent` re-compiles the class with the information set by `setClassMetadata`. `setClassMetadata` only captures decorated members at the moment.

These changes introduce some logic to capture the new initializer-based APIs in `setClassMetadata` as well.

Fixes angular#57944.
@crisbeto crisbeto force-pushed the 61229/signals-set-class-metadata branch from e22d5c1 to 341e7d1 Compare September 18, 2025 18:25
@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Sep 18, 2025
thePunderWoman pushed a commit that referenced this pull request Sep 18, 2025
Reworks the logic that tracks the decorator metadata for members to do so using the output AST, rather than wrapping the TypeScript AST. This makes it easier to programmatically generate new members that weren't part of the TypeScript AST before.

PR Close #63904
thePunderWoman pushed a commit that referenced this pull request Sep 18, 2025
Adds the member decorators to the map of exposed compiler symbols.

PR Close #63904
thePunderWoman pushed a commit that referenced this pull request Sep 18, 2025
Currently if `TestBed.overrideComponent` is used on a class that uses initializer APIs (e.g. `input()`), the initializer metadata will be wiped out, because `overrideComponent` re-compiles the class with the information set by `setClassMetadata`. `setClassMetadata` only captures decorated members at the moment.

These changes introduce some logic to capture the new initializer-based APIs in `setClassMetadata` as well.

Fixes #57944.

PR Close #63904
@thePunderWoman
Copy link
Contributor

This PR was merged into the repository. The changes were merged into the following branches:

thePunderWoman pushed a commit that referenced this pull request Sep 18, 2025
Adds the member decorators to the map of exposed compiler symbols.

PR Close #63904
thePunderWoman pushed a commit that referenced this pull request Sep 18, 2025
Currently if `TestBed.overrideComponent` is used on a class that uses initializer APIs (e.g. `input()`), the initializer metadata will be wiped out, because `overrideComponent` re-compiles the class with the information set by `setClassMetadata`. `setClassMetadata` only captures decorated members at the moment.

These changes introduce some logic to capture the new initializer-based APIs in `setClassMetadata` as well.

Fixes #57944.

PR Close #63904
thePunderWoman added a commit to thePunderWoman/angular that referenced this pull request Sep 19, 2025
thePunderWoman added a commit to thePunderWoman/angular that referenced this pull request Sep 19, 2025
thePunderWoman added a commit to thePunderWoman/angular that referenced this pull request Sep 19, 2025
thePunderWoman added a commit that referenced this pull request Sep 19, 2025
thePunderWoman added a commit that referenced this pull request Sep 19, 2025
thePunderWoman added a commit that referenced this pull request Sep 19, 2025
thePunderWoman added a commit that referenced this pull request Sep 19, 2025
thePunderWoman added a commit that referenced this pull request Sep 19, 2025
thePunderWoman added a commit that referenced this pull request Sep 19, 2025
@thePunderWoman
Copy link
Contributor

@crisbeto We had to revert this due to a test breakage in G3.

@thePunderWoman thePunderWoman added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews requires: TGP This PR requires a passing TGP before merging is allowed and removed action: merge The PR is ready for merge by the caretaker labels Sep 19, 2025
@pullapprove pullapprove bot removed the requires: TGP This PR requires a passing TGP before merging is allowed label Sep 19, 2025
@JeanMeche JeanMeche added the action: global presubmit The PR is in need of a google3 global presubmit label Sep 19, 2025
@crisbeto
Copy link
Member Author

Will open a new PR.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Oct 20, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews action: global presubmit The PR is in need of a google3 global presubmit area: compiler Issues related to `ngc`, Angular's template compiler target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Initializer APIs (input, output, queries) not integrating with TestBed.override in a jit & aot mix

4 participants