Skip to content

Fixed multiple prologue directives with parameter properties - #48687

Merged
Jake Bailey (jakebailey) merged 1 commit into
microsoft:mainfrom
JoshuaKGoldberg:fix-parameter-properties-and-prologue-directives
Apr 14, 2022
Merged

Fixed multiple prologue directives with parameter properties#48687
Jake Bailey (jakebailey) merged 1 commit into
microsoft:mainfrom
JoshuaKGoldberg:fix-parameter-properties-and-prologue-directives

Conversation

@JoshuaKGoldberg

@JoshuaKGoldberg Josh Goldberg ✨ (JoshuaKGoldberg) commented Apr 13, 2022

Copy link
Copy Markdown
Contributor

Two issues:

  • Parameter properties should be inserted after any prologue directives
  • Prologue directives were getting copied over twice when there wasn't a super()

Fixes #48671

Comment thread src/compiler/checker.ts
break;
}
if (!isPrologueDirective(statement) && nodeImmediatelyReferencesSuperOrThis(statement)) {
if (nodeImmediatelyReferencesSuperOrThis(statement)) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This change isn't necessary for the PR; I just had only noticed the check is unnecessary after #29374 was merged 😄

const indexAfterLastPrologueStatement = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor);
const superStatementIndex = findSuperStatementIndex(body.statements, indexAfterLastPrologueStatement);
const prologueStatementCount = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor);
const superStatementIndex = findSuperStatementIndex(body.statements, prologueStatementCount);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm nitpicking the variable name here. Both variable names are correct; prologueStatementCount just makes more sense to me -- especially in the context of the new array spread below.

@JoshuaKGoldberg
Josh Goldberg ✨ (JoshuaKGoldberg) marked this pull request as ready for review April 13, 2022 23:44
@jakebailey
Jake Bailey (jakebailey) merged commit fa2515e into microsoft:main Apr 14, 2022
@jakebailey

Copy link
Copy Markdown
Member

Thanks for fixing this!

@jakebailey

Copy link
Copy Markdown
Member

TypeScript Bot (@typescript-bot) cherry-pick this to release-4.6

@typescript-bot

TypeScript Bot (typescript-bot) commented Apr 20, 2022

Copy link
Copy Markdown
Contributor

Heya Jake Bailey (@jakebailey), I've started to run the task to cherry-pick this into release-4.6 on this PR at 76f482f. You can monitor the build here.

@typescript-bot

Copy link
Copy Markdown
Contributor

Hey Jake Bailey (@jakebailey), I couldn't open a PR with the cherry-pick. (You can check the log here). You may need to squash and pick this PR into release-4.6 manually.

@jakebailey

Copy link
Copy Markdown
Member

Sent #48782 manually. This PR is needed for the other PRs thanks to this PR affecting the base ts.ts transform.

Daniel Rosenwasser (DanielRosenwasser) pushed a commit that referenced this pull request May 3, 2022
…#48782)

Co-authored-by: Josh Goldberg <me@joshuakgoldberg.com>
@microsoft 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

For Milestone Bug PRs that fix a bug with a specific milestone

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No-op string in constructor is repeated and reordered when constructor assignment is used

3 participants