Skip to content

Commit

Permalink
avoid add parentheses for async do expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Mar 26, 2021
1 parent 449e416 commit dd438d0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion packages/babel-generator/src/node/parentheses.ts
Expand Up @@ -82,7 +82,8 @@ export function DoExpression(
parent: any,
printStack: Array<any>,
): boolean {
return isFirstInStatement(printStack);
// `async do` can start an expression statement
return !node.async && isFirstInStatement(printStack);
}

export function Binary(node: any, parent: any): boolean {
Expand Down
@@ -1,5 +1,5 @@
(async do {
async do {
1;
});
};

(async do {});
@@ -1,4 +1,4 @@
(async do {
async do {
1;
});
(async do {});
};
async do {};
@@ -1,3 +1,3 @@
/* leading comments
*/(async do
{1;}) + 0;
*/async do
{1;} + 0;

0 comments on commit dd438d0

Please sign in to comment.