From 615160ba66a05e1b6a83dc1d3e590d3d02ff336f Mon Sep 17 00:00:00 2001 From: phantom10111 Date: Tue, 24 Nov 2015 22:42:14 +0100 Subject: [PATCH] Fix babel-helper-remap-async-to-generator to not fail with the new validation rules --- .../babel-helper-remap-async-to-generator/src/index.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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 a8ba68f0be..9984c662c1 100644 --- a/packages/babel-helper-remap-async-to-generator/src/index.js +++ b/packages/babel-helper-remap-async-to-generator/src/index.js @@ -53,6 +53,12 @@ function plainFunction(path: NodePath, callId: Object) { let asyncFnId = node.id; node.id = null; + let isDeclaration = path.isFunctionDeclaration(); + + if (isDeclaration) { + node.type = "FunctionExpression"; + } + let built = t.callExpression(callId, [node]); let container = buildWrapper({ FUNCTION: built, @@ -61,9 +67,7 @@ function plainFunction(path: NodePath, callId: Object) { let retFunction = container.body.body[1].argument; - if (path.isFunctionDeclaration()) { - node.type = "FunctionExpression"; - + if (isDeclaration) { let declar = t.variableDeclaration("let", [ t.variableDeclarator( t.identifier(asyncFnId.name),