Skip to content

Commit be74623

Browse files
committed
fix: prevent infinite loop in check if handler arg is function
fix #24
1 parent f98a483 commit be74623

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/util/canDefinitelyInvoke.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,15 @@ export default function canDefinitelyInvoke<T extends t.Node>(
88
let target: NodePath<any> | undefined = expr
99
while (target) {
1010
if (target.isIdentifier()) {
11-
target = target.scope.getBinding(target.node.name)?.path
11+
const nextTarget: NodePath<any> | undefined = target.scope.getBinding(
12+
target.node.name
13+
)?.path
14+
if (
15+
nextTarget === target ||
16+
(nextTarget && nextTarget.node === target.node)
17+
)
18+
break
19+
target = nextTarget
1220
} else if (target.isVariableDeclarator()) {
1321
target = (target as NodePath<t.VariableDeclarator>).get('init')
1422
} else {

0 commit comments

Comments
 (0)