Fix recursive async function expressions (#9039)
* Fix recursive async function expressions * Update fixtures
This commit is contained in:
@@ -3,7 +3,7 @@ import nameFunction from "@babel/helper-function-name";
|
||||
import template from "@babel/template";
|
||||
import * as t from "@babel/types";
|
||||
|
||||
const buildExpressionWrapper = template.expression(`
|
||||
const buildAnonymousExpressionWrapper = template.expression(`
|
||||
(function () {
|
||||
var REF = FUNCTION;
|
||||
return function NAME(PARAMS) {
|
||||
@@ -12,6 +12,16 @@ const buildExpressionWrapper = template.expression(`
|
||||
})()
|
||||
`);
|
||||
|
||||
const buildNamedExpressionWrapper = template.expression(`
|
||||
(function () {
|
||||
var REF = FUNCTION;
|
||||
function NAME(PARAMS) {
|
||||
return REF.apply(this, arguments);
|
||||
}
|
||||
return NAME;
|
||||
})()
|
||||
`);
|
||||
|
||||
const buildDeclarationWrapper = template(`
|
||||
function NAME(PARAMS) { return REF.apply(this, arguments); }
|
||||
function REF() {
|
||||
@@ -53,7 +63,9 @@ function plainFunction(path: NodePath, callId: Object) {
|
||||
const functionId = node.id;
|
||||
const wrapper = isDeclaration
|
||||
? buildDeclarationWrapper
|
||||
: buildExpressionWrapper;
|
||||
: functionId
|
||||
? buildNamedExpressionWrapper
|
||||
: buildAnonymousExpressionWrapper;
|
||||
|
||||
if (path.isArrowFunctionExpression()) {
|
||||
path.arrowFunctionToExpression();
|
||||
|
||||
Reference in New Issue
Block a user