Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit parens for await of ternary expressions #5270

Merged
merged 1 commit into from Feb 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/babel-generator/src/node/parentheses.js
Expand Up @@ -197,6 +197,10 @@ export function ConditionalExpression(node: Object, parent: Object): boolean {
return true;
}

if (t.isAwaitExpression(parent)) {
return true;
}

return UnaryLike(node, parent);
}

Expand Down
Expand Up @@ -3,6 +3,7 @@ async function asdf() {
(await b)();
new (await b)();
true ? (await 1) : (await 2);
await (1 ? 2 : 3);
await (await 1);
}

Expand Down
Expand Up @@ -3,6 +3,7 @@ async function asdf() {
(await b)();
new (await b)();
true ? await 1 : await 2;
await (1 ? 2 : 3);
await await 1;
}

Expand Down
Expand Up @@ -3,6 +3,7 @@ function* asdf() {
(yield b)();
new (yield b)();
(yield 1) ? (yield 2) : (yield 3);
yield (1 ? 2 : 3);
yield (yield 1);
}

Expand Down
Expand Up @@ -3,6 +3,7 @@ function* asdf() {
(yield b)();
new (yield b)();
(yield 1) ? yield 2 : yield 3;
yield 1 ? 2 : 3;
yield yield 1;
}

Expand Down