Skip to content

Commit 916ee46

Browse files
authored
fix: helper-wrap-function compat with traverse (#14825)
1 parent a196459 commit 916ee46

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

  • packages/babel-helper-wrap-function/src

packages/babel-helper-wrap-function/src/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,12 @@ function plainFunction(
9797
let functionId = null;
9898
let node;
9999
if (path.isArrowFunctionExpression()) {
100-
path = path.arrowFunctionToExpression({ noNewArrows });
100+
if (process.env.BABEL_8_BREAKING) {
101+
path = path.arrowFunctionToExpression({ noNewArrows });
102+
} else {
103+
// arrowFunctionToExpression returns undefined in @babel/traverse < 7.18.10
104+
path = path.arrowFunctionToExpression({ noNewArrows }) ?? path;
105+
}
101106
node = path.node as t.FunctionDeclaration | t.FunctionExpression;
102107
} else {
103108
node = path.node as t.FunctionDeclaration | t.FunctionExpression;

0 commit comments

Comments
 (0)