Skip to content

Commit

Permalink
fix: helper-wrap-function compat with traverse (#14825)
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Aug 4, 2022
1 parent a196459 commit 916ee46
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/babel-helper-wrap-function/src/index.ts
Expand Up @@ -97,7 +97,12 @@ function plainFunction(
let functionId = null;
let node;
if (path.isArrowFunctionExpression()) {
path = path.arrowFunctionToExpression({ noNewArrows });
if (process.env.BABEL_8_BREAKING) {
path = path.arrowFunctionToExpression({ noNewArrows });
} else {
// arrowFunctionToExpression returns undefined in @babel/traverse < 7.18.10
path = path.arrowFunctionToExpression({ noNewArrows }) ?? path;
}
node = path.node as t.FunctionDeclaration | t.FunctionExpression;
} else {
node = path.node as t.FunctionDeclaration | t.FunctionExpression;
Expand Down

0 comments on commit 916ee46

Please sign in to comment.