MCPcopy Create free account
hub / github.com/babel/babel / arrayUnpackVisitor

Function arrayUnpackVisitor

packages/babel-plugin-transform-destructuring/src/util.ts:60–79  ·  view source on GitHub ↗
(
  node: t.Node,
  ancestors: t.TraversalAncestors,
  state: ArrayUnpackVisitorState,
)

Source from the content-addressed store, hash-verified

58
59// NOTE: This visitor is meant to be used via t.traverse
60const arrayUnpackVisitor = (
61 node: t.Node,
62 ancestors: t.TraversalAncestors,
63 state: ArrayUnpackVisitorState,
64) => {
65 if (!ancestors.length) {
66 // Top-level node: this is the array literal.
67 return;
68 }
69
70 if (
71 t.isIdentifier(node) &&
72 t.isReferenced(node, ancestors[ancestors.length - 1].node) &&
73 state.bindings[node.name]
74 ) {
75 state.deopt = true;
76 // eslint-disable-next-line @typescript-eslint/only-throw-error
77 throw STOP_TRAVERSAL;
78 }
79};
80
81export type DestructuringTransformerNode =
82 t.VariableDeclaration | t.ExpressionStatement | t.ReturnStatement;

Callers

nothing calls this directly

Calls 2

isIdentifierMethod · 0.80
isReferencedMethod · 0.80

Tested by

no test coverage detected