diff --git a/packages/babel-helper-remap-async-to-generator/src/index.js b/packages/babel-helper-remap-async-to-generator/src/index.js index a7600e413a..840a195d8a 100644 --- a/packages/babel-helper-remap-async-to-generator/src/index.js +++ b/packages/babel-helper-remap-async-to-generator/src/index.js @@ -123,7 +123,7 @@ function plainFunction(path: NodePath, callId: Object) { REF: path.scope.generateUidIdentifier("ref"), FUNCTION: built, PARAMS: node.params.reduce((acc, param) => { - acc.done = acc.done || !t.isIdentifier(param); + acc.done = acc.done || t.isAssignmentPattern(param) || t.isRestElement(param); if (!acc.done) { acc.params.push(path.scope.generateUidIdentifier("x")); diff --git a/packages/babel-plugin-transform-async-to-generator/test/fixtures/async-to-generator/function-arity/actual.js b/packages/babel-plugin-transform-async-to-generator/test/fixtures/async-to-generator/function-arity/actual.js index 492289af70..a08e67e7f3 100644 --- a/packages/babel-plugin-transform-async-to-generator/test/fixtures/async-to-generator/function-arity/actual.js +++ b/packages/babel-plugin-transform-async-to-generator/test/fixtures/async-to-generator/function-arity/actual.js @@ -1,4 +1,6 @@ async function one(a, b = 1) {} async function two(a, b, ...c) {} async function three(a, b = 1, c, d = 3) {} -async function four(a, b = 1, c, ...d) {} \ No newline at end of file +async function four(a, b = 1, c, ...d) {} +async function five(a, {b}){} +async function six(a, {b} = {}){} diff --git a/packages/babel-plugin-transform-async-to-generator/test/fixtures/async-to-generator/function-arity/expected.js b/packages/babel-plugin-transform-async-to-generator/test/fixtures/async-to-generator/function-arity/expected.js index 1db5d28058..e74b618424 100644 --- a/packages/babel-plugin-transform-async-to-generator/test/fixtures/async-to-generator/function-arity/expected.js +++ b/packages/babel-plugin-transform-async-to-generator/test/fixtures/async-to-generator/function-arity/expected.js @@ -28,4 +28,20 @@ let four = (() => { return function four(_x5) { return _ref4.apply(this, arguments); }; +})(); + +let five = (() => { + var _ref5 = babelHelpers.asyncToGenerator(function* (a, { b }) {}); + + return function five(_x6, _x7) { + return _ref5.apply(this, arguments); + }; +})(); + +let six = (() => { + var _ref6 = babelHelpers.asyncToGenerator(function* (a, { b } = {}) {}); + + return function six(_x8) { + return _ref6.apply(this, arguments); + }; })(); \ No newline at end of file