Add a check for parentheses for AwaitExpressions (fixes T6913)
This commit is contained in:
@@ -144,6 +144,16 @@ export function SequenceExpression(node: Object, parent: Object): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
export function AwaitExpression(node: Object, parent: Object): boolean {
|
||||
return t.isBinary(parent) ||
|
||||
t.isUnaryLike(parent) ||
|
||||
t.isCallExpression(parent) ||
|
||||
t.isMemberExpression(parent) ||
|
||||
t.isNewExpression(parent) ||
|
||||
t.isConditionalExpression(parent) ||
|
||||
t.isAwaitExpression(parent);
|
||||
}
|
||||
|
||||
export function YieldExpression(node: Object, parent: Object): boolean {
|
||||
return t.isBinary(parent) ||
|
||||
t.isUnaryLike(parent) ||
|
||||
|
||||
11
packages/babel-generator/test/fixtures/parentheses/await-expression/actual.js
vendored
Normal file
11
packages/babel-generator/test/fixtures/parentheses/await-expression/actual.js
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
async function asdf() {
|
||||
(await 1) || (await 2);
|
||||
(await b)();
|
||||
new (await b)();
|
||||
true ? (await 1) : (await 2);
|
||||
await (await 1);
|
||||
}
|
||||
|
||||
async function a(b) {
|
||||
(await xhr({ url: "views/test.html" })).data;
|
||||
}
|
||||
11
packages/babel-generator/test/fixtures/parentheses/await-expression/expected.js
vendored
Normal file
11
packages/babel-generator/test/fixtures/parentheses/await-expression/expected.js
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
async function asdf() {
|
||||
(await 1) || (await 2);
|
||||
(await b)();
|
||||
new (await b)();
|
||||
true ? (await 1) : (await 2);
|
||||
await (await 1);
|
||||
}
|
||||
|
||||
async function a(b) {
|
||||
(await xhr({ url: "views/test.html" })).data;
|
||||
}
|
||||
Reference in New Issue
Block a user