Skip to content

fix(compiler-cli): avoid ECMAScript private field metadata emit#61227

Closed
clydin wants to merge 1 commit intoangular:mainfrom
clydin:compiler/no-private-class-metadata
Closed

fix(compiler-cli): avoid ECMAScript private field metadata emit#61227
clydin wants to merge 1 commit intoangular:mainfrom
clydin:compiler/no-private-class-metadata

Conversation

@clydin
Copy link
Copy Markdown
Member

@clydin clydin commented May 8, 2025

The Angular class metadata emit structure does not support the use of private fields. If the class metadata emit is enabled and an ECMAScript private (i.e., # prefixed) member contains a decorator, the member will now be excluded from the emitting setClassMetadata call. This prevents runtime errors due to invalid syntax. This class member usage is only permitted if standard ECMAScript decorators are used.

Closes #61228

@clydin clydin requested a review from JoostK May 8, 2025 20:56
@clydin clydin added the target: patch This PR is targeted for the next patch release label May 8, 2025
@angular-robot angular-robot bot added the area: compiler Issues related to `ngc`, Angular's template compiler label May 8, 2025
@ngbot ngbot bot added this to the Backlog milestone May 8, 2025
@clydin clydin linked an issue May 8, 2025 that may be closed by this pull request
1 task
@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label May 8, 2025
Copy link
Copy Markdown
Member

@JoostK JoostK left a comment

Choose a reason for hiding this comment

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

One nit

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I now wonder if private fields are supported for Angular-decorated symbols at all. If they are, this change would mean that such fields would generally work except for being JIT-compatible, as that's where the metadata transform (especially for signal-based inputs) is relevant.

Since this change primarily targets non-Angular decorators this point it irrelevant to fix the reported issue so no further actions needed for now.

@clydin clydin force-pushed the compiler/no-private-class-metadata branch 2 times, most recently from 8a230f0 to 8040007 Compare May 12, 2025 13:57
The Angular class metadata emit structure does not support the use of
private fields. If the class metadata emit is enabled and an ECMAScript
private (i.e., `#` prefixed) member contains a decorator, the member will
now be excluded from the emitting `setClassMetadata` call. This prevents
runtime errors due to invalid syntax.
@clydin clydin force-pushed the compiler/no-private-class-metadata branch from 8040007 to 59d6c99 Compare May 12, 2025 14:19
@clydin clydin 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 May 15, 2025
@alxhub
Copy link
Copy Markdown
Member

alxhub commented May 15, 2025

This PR was merged into the repository by commit c0cd3c2.

The changes were merged into the following branches: main, 19.2.x, 20.0.x

@alxhub alxhub closed this in c0cd3c2 May 15, 2025
alxhub pushed a commit that referenced this pull request May 15, 2025
The Angular class metadata emit structure does not support the use of
private fields. If the class metadata emit is enabled and an ECMAScript
private (i.e., `#` prefixed) member contains a decorator, the member will
now be excluded from the emitting `setClassMetadata` call. This prevents
runtime errors due to invalid syntax.

PR Close #61227
alxhub pushed a commit that referenced this pull request May 15, 2025
The Angular class metadata emit structure does not support the use of
private fields. If the class metadata emit is enabled and an ECMAScript
private (i.e., `#` prefixed) member contains a decorator, the member will
now be excluded from the emitting `setClassMetadata` call. This prevents
runtime errors due to invalid syntax.

PR Close #61227
@clydin clydin deleted the compiler/no-private-class-metadata branch May 15, 2025 16:45
@angular-automatic-lock-bot
Copy link
Copy Markdown

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 Jun 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker 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.

Unable to use JS decorators in private methods with the development build

3 participants