-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 constructor code when there is code between prologue statements and super call #48765
Conversation
…statements and super call
@@ -1146,7 +1146,7 @@ namespace ts { | |||
[ | |||
...existingPrologue, | |||
...prologue, | |||
...(superStatementIndex <= existingPrologue.length ? emptyArray : visitNodes(constructor.body.statements, visitor, isStatement, existingPrologue.length, superStatementIndex)), | |||
...(superStatementIndex <= existingPrologue.length ? emptyArray : visitNodes(constructor.body.statements, visitor, isStatement, existingPrologue.length, superStatementIndex - existingPrologue.length)), |
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.
The last argument is count
and not end
, so I believe the fix is to substract the start position from here. Otherwise we're processing too many nodes (including super()
)
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.
Good catch!
@jakebailey any chance we can port this to 4.6.x? Maybe together with #48671 which is related. It's currently blocking my team from upgrading to 4.6.x |
Yes, I think both should be backported. @DanielRosenwasser |
@typescript-bot cherry-pick this to release-4.6 |
Heya @jakebailey, I've started to run the task to cherry-pick this into |
Hey @jakebailey, I've opened #48780 for you. |
Component commits: 1b9a9d8 Fix transformed constructor code when there is code between prologue statements and super call
…statements and super call (microsoft#48765)
Component commits: 1b9a9d8 Fix transformed constructor code when there is code between prologue statements and super call Co-authored-by: Patrick Szmucer <pszmucer@palantir.com>
Fixes #48761
cc @JoshuaKGoldberg