Skip to content

Conversation

@rbuckton
Copy link
Contributor

The issue occurs because substitution assumes a this in a static PropertyDeclaration can only occur in an initializer, and part of performing this check includes looking at the original node for the declaration containing the this. However, an accessor is also transformed into a get/set pair that contains this, and those generated get and set methods will also have their original node set to the same PropertyDeclaration as the initializer, which results in overzealous substitution.

This PR changes the behavior to prevent substitution of the this keyword in the generated calls to __classPrivateFieldGet and __classPrivateFieldSet in the generated get and set methods.

Fixes #54473

@rbuckton rbuckton requested review from jakebailey and weswigham May 31, 2023 14:51
@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels May 31, 2023
@rbuckton rbuckton merged commit 4c01b2f into main May 31, 2023
@rbuckton rbuckton deleted the fix-54473 branch May 31, 2023 22:17
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

this incorrectly transformed to _classThis in downlevel static accessor

4 participants