-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Fix handling of prologue statements when there are parameter property declarations #48775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix handling of prologue statements when there are parameter property declarations #48775
Conversation
parameter property declarations If there is a prologue (and no super) in a constructor, the prologue won't be skipped when calculating the parameter properties, leading to the prologue being included twice
Would you mind adding in the second test from #48771 (comment)? |
statements[0], | ||
...statements.slice(0, superAndPrologueStatementCount), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated so we include parameter properties after any prologues - I believe this is the correct way of doing it, since that's what the existing TS version does
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM; notably, #29374 modified three transforms:
ts.ts
, fixed in Fixed multiple prologue directives with parameter properties #48687es2015.ts
, fixed in Fix constructor code when there is code between prologue statements and super call #48765classFields.ts
, fixed in this PR.
I'm hoping that's the last of this bug.
@typescript-bot cherry-pick this to release-4.6 |
Heya @jakebailey, I've started to run the task to cherry-pick this into |
Component commits: 74c337b Fix handling of prologue statements when there are parameter property declarations If there is a prologue (and no super) in a constructor, the prologue won't be skipped when calculating the parameter properties, leading to the prologue being included twice bd2a2ec Add second test case d45098e Update to match old TS version: parameter properties after prologue 891cb6f Parametert properties should be added after any prologue
Hey @jakebailey, I've opened #48781 for you. |
Component commits: 74c337b Fix handling of prologue statements when there are parameter property declarations If there is a prologue (and no super) in a constructor, the prologue won't be skipped when calculating the parameter properties, leading to the prologue being included twice bd2a2ec Add second test case d45098e Update to match old TS version: parameter properties after prologue 891cb6f Parametert properties should be added after any prologue Co-authored-by: John Lusty <[email protected]>
Had a chance to have a look into this, and I think I've found the solution to the issue I raised: if there is a prologue (and no super) in a constructor, the prologue won't be skipped when calculating the parameter properties, leading to the prologue being included twice.
Please let me know if I need to update/change anything - I hope I added the tests correctly, all the tests are still passing.
Fixes #48771