diff --git a/src/helpers/functions.lsc b/src/helpers/functions.lsc index 7fda331..597613d 100644 --- a/src/helpers/functions.lsc +++ b/src/helpers/functions.lsc @@ -21,10 +21,7 @@ export addImplicitReturns(functionPath) -> throw path.buildCodeFrameError("Ambiguous implicit `return` of multiple variables. " + "Add an explicit `return` statement on the next line.") - if expr~isa("AwaitExpression"): - t.returnStatement(expr.argument)~atNode(expr) - else: - t.returnStatement(expr)~atNode(expr) + t.returnStatement(expr)~atNode(expr) transformTails( functionPath.get("body") diff --git a/test/fixtures/arrow-function-expressions/async/expected.js b/test/fixtures/arrow-function-expressions/async/expected.js index 522f7f6..afcddf9 100644 --- a/test/fixtures/arrow-function-expressions/async/expected.js +++ b/test/fixtures/arrow-function-expressions/async/expected.js @@ -1,4 +1,4 @@ (async function () { await 1; - return 2; + return await 2; }); \ No newline at end of file diff --git a/test/fixtures/arrow-function-expressions/fat-async/expected.js b/test/fixtures/arrow-function-expressions/fat-async/expected.js index ac80d40..d6345a6 100644 --- a/test/fixtures/arrow-function-expressions/fat-async/expected.js +++ b/test/fixtures/arrow-function-expressions/fat-async/expected.js @@ -1,4 +1,4 @@ async () => { await 1; - return 2; + return await 2; }; \ No newline at end of file diff --git a/test/fixtures/arrow-methods-class/fat-async/expected.js b/test/fixtures/arrow-methods-class/fat-async/expected.js index e8bd179..0f9f0a1 100644 --- a/test/fixtures/arrow-methods-class/fat-async/expected.js +++ b/test/fixtures/arrow-methods-class/fat-async/expected.js @@ -4,6 +4,6 @@ class A { } async f() { - return this; + return await this; } } \ No newline at end of file diff --git a/test/fixtures/arrow-methods-obj/fat-async/expected.js b/test/fixtures/arrow-methods-obj/fat-async/expected.js index d5e1c47..8f9cfee 100644 --- a/test/fixtures/arrow-methods-obj/fat-async/expected.js +++ b/test/fixtures/arrow-methods-obj/fat-async/expected.js @@ -1,5 +1,5 @@ const o = { async f() { - return this; + return await this; } }; o.f = o.f.bind(o); \ No newline at end of file diff --git a/test/fixtures/arrow-methods-obj/skinny-async/expected.js b/test/fixtures/arrow-methods-obj/skinny-async/expected.js index 753bdba..c272b87 100644 --- a/test/fixtures/arrow-methods-obj/skinny-async/expected.js +++ b/test/fixtures/arrow-methods-obj/skinny-async/expected.js @@ -1,4 +1,4 @@ const o = { async f(x) { - return x; + return await x; } }; \ No newline at end of file diff --git a/test/fixtures/await-arrow/await-array/expected.js b/test/fixtures/await-arrow/await-array/expected.js index 5ecc10f..e6abfd4 100644 --- a/test/fixtures/await-arrow/await-array/expected.js +++ b/test/fixtures/await-arrow/await-array/expected.js @@ -1,7 +1,7 @@ async function fn() { const x = await Promise.all([p1, p2]); const y = await Promise.all([p1, p2]); - return Promise.all((() => { + return await Promise.all((() => { const _arr = [];for (const p of ps) _arr.push(p);return _arr; })()); } \ No newline at end of file diff --git a/test/fixtures/await-arrow/safe-statement/expected.js b/test/fixtures/await-arrow/safe-statement/expected.js index 564c9d5..3966bc7 100644 --- a/test/fixtures/await-arrow/safe-statement/expected.js +++ b/test/fixtures/await-arrow/safe-statement/expected.js @@ -1,5 +1,5 @@ async function fn() { - return (async () => { + return await (async () => { try { return await fetch(); } catch (_err) { diff --git a/test/fixtures/await-arrow/statement/expected.js b/test/fixtures/await-arrow/statement/expected.js index aefdbc5..75cce51 100644 --- a/test/fixtures/await-arrow/statement/expected.js +++ b/test/fixtures/await-arrow/statement/expected.js @@ -1,3 +1,3 @@ async function fn() { - return fetch(); + return await fetch(); } \ No newline at end of file diff --git a/test/fixtures/named-arrow-functions/async/expected.js b/test/fixtures/named-arrow-functions/async/expected.js index 154fae1..770c8c3 100644 --- a/test/fixtures/named-arrow-functions/async/expected.js +++ b/test/fixtures/named-arrow-functions/async/expected.js @@ -1,4 +1,4 @@ async function fn() { await 1; - return 2; + return await 2; } \ No newline at end of file diff --git a/test/fixtures/named-arrow-functions/fat-async/expected.js b/test/fixtures/named-arrow-functions/fat-async/expected.js index 8d44b0e..aed77cf 100644 --- a/test/fixtures/named-arrow-functions/fat-async/expected.js +++ b/test/fixtures/named-arrow-functions/fat-async/expected.js @@ -1,4 +1,4 @@ const fn = async () => { await 1; - return 2; + return await 2; }; \ No newline at end of file