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

This commit is contained in:
Ika authored and GitHub committed 2018-06-30 23:15:45 +08:00
1 parent d450882289
commit 61d5eeadd3
3 files changed
+31

No files matched your search

+1
View File
@@ -369,6 +369,7 @@ function needsParens(path, options) {
case "ExperimentalSpreadProperty":
case "TSAsExpression":
case "TSNonNullExpression":
case "BindExpression":
return true;
case "MemberExpression":
@@ -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);
+4
View File
@@ -0,0 +1,4 @@
const doBothThings = async () => {
const request = doAsyncThing();
return (await request)::doSyncThing();
};