Skip to content

Add preceding semicolon on await insertion when parentheses are included #34627

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

Merged
merged 5 commits into from
Nov 19, 2019

Conversation

andrewbranch
Copy link
Member

Fixes #33522

Copy link
Contributor

@Kingwl Kingwl left a comment

Choose a reason for hiding this comment

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

Looks good, thanks

index: 0,
newFileContent:
`async function fn(a: Promise<{ x: string }>) {
console.log(3)
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this have ; after console.log and on that line instead of next line ?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is actually the typical preferred style for non-semicoloners. See https://standardjs.com/rules.html#semicolons

Copy link
Member Author

Choose a reason for hiding this comment

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

/cc @orta to confirm people actually do this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Prettier does it this way, to which I give more credence than StandardJS anyway. I feel good about keeping it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, confirming, this is what I'm used to

@@ -257,6 +257,7 @@ namespace ts.codefix {
sourceFile,
insertionSite.parent.expression,
createParen(createAwait(insertionSite.parent.expression)));
insertLeadingSemicolonIfNeeded(changeTracker, insertionSite.parent.expression, sourceFile);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
insertLeadingSemicolonIfNeeded(changeTracker, insertionSite.parent.expression, sourceFile);
insertLeadingSemicolonIfNeeded(changeTracker, insertionSite.parent.expression, sourceFile);

Copy link
Member Author

@andrewbranch andrewbranch Nov 18, 2019

Choose a reason for hiding this comment

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

The current indentation is correct (the preceding three lines are arguments to replaceNode; this is not)

@andrewbranch andrewbranch merged commit 571ca60 into microsoft:master Nov 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Await insert break ASI
5 participants