Fix bodyless async functions (#4600)
* fix bodyless async functions (#4599) * Do the same in the async-generator-functions transform
This commit is contained in:
parent
6d82ee297e
commit
682e9658c9
@ -152,7 +152,7 @@ function plainFunction(path: NodePath, callId: Object) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function (path: NodePath, file: Object, helpers: Object) {
|
export default function (path: NodePath, file: Object, helpers: Object) {
|
||||||
path.get("body").traverse(awaitVisitor, {
|
path.traverse(awaitVisitor, {
|
||||||
file,
|
file,
|
||||||
wrapAwait: helpers.wrapAwait
|
wrapAwait: helpers.wrapAwait
|
||||||
});
|
});
|
||||||
|
|||||||
@ -22,7 +22,7 @@ export default function ({ types: t }) {
|
|||||||
Function(path, state) {
|
Function(path, state) {
|
||||||
if (!path.node.async || !path.node.generator) return;
|
if (!path.node.async || !path.node.generator) return;
|
||||||
|
|
||||||
path.get("body").traverse(yieldStarVisitor, state);
|
path.traverse(yieldStarVisitor, state);
|
||||||
|
|
||||||
remapAsyncToGenerator(path, state.file, {
|
remapAsyncToGenerator(path, state.file, {
|
||||||
wrapAsync: t.memberExpression(
|
wrapAsync: t.memberExpression(
|
||||||
|
|||||||
3
packages/babel-plugin-transform-async-to-generator/test/fixtures/regression/4599/actual.js
vendored
Normal file
3
packages/babel-plugin-transform-async-to-generator/test/fixtures/regression/4599/actual.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
async () => await promise
|
||||||
|
|
||||||
|
async () => { await promise }
|
||||||
7
packages/babel-plugin-transform-async-to-generator/test/fixtures/regression/4599/expected.js
vendored
Normal file
7
packages/babel-plugin-transform-async-to-generator/test/fixtures/regression/4599/expected.js
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
babelHelpers.asyncToGenerator(function* () {
|
||||||
|
return yield promise;
|
||||||
|
});
|
||||||
|
|
||||||
|
babelHelpers.asyncToGenerator(function* () {
|
||||||
|
yield promise;
|
||||||
|
});
|
||||||
Loading…
x
Reference in New Issue
Block a user