fix(javascript): add parens for await in bind (#4778)

master
Ika 2018-06-30 23:15:45 +08:00 committed by GitHub
parent d450882289
commit 61d5eeadd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 0 deletions

View File

@ -369,6 +369,7 @@ function needsParens(path, options) {
case "ExperimentalSpreadProperty":
case "TSAsExpression":
case "TSNonNullExpression":
case "BindExpression":
return true;
case "MemberExpression":

View File

@ -1,5 +1,31 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`await.js 1`] = `
const doBothThings = async () => {
const request = doAsyncThing();
return (await request)::doSyncThing();
};
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const doBothThings = async () => {
const request = doAsyncThing();
return (await request)::doSyncThing();
};
`;
exports[`await.js 2`] = `
const doBothThings = async () => {
const request = doAsyncThing();
return (await request)::doSyncThing();
};
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const doBothThings = async () => {
const request = doAsyncThing()
return (await request)::doSyncThing()
}
`;
exports[`bind_parens.js 1`] = `
(a || b)::c;
a || (b::c);

View File

@ -0,0 +1,4 @@
const doBothThings = async () => {
const request = doAsyncThing();
return (await request)::doSyncThing();
};