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

Function startNodeAtNode

packages/babel-parser/src/parser/node.ts:71–88  ·  view source on GitHub ↗

Start a new node with a previous node's location.

(
    type: Undone<NodeType>,
  )

Source from the content-addressed store, hash-verified

69
70 /** Start a new node with a previous node's location. */
71 startNodeAtNode<T extends NodeType = never>(
72 type: Undone<NodeType>,
73 ): Undone<T> {
74 const { optionFlags, filename } = this;
75 if (!(optionFlags & OptionFlags.Locations)) {
76 return new Node(
77 optionFlags,
78 filename,
79 type.start!,
80 ) as unknown as Undone<T>;
81 }
82 return new Node(
83 optionFlags,
84 filename,
85 type.start!,
86 type.loc!.start,
87 ) as unknown as Undone<T>;
88 }
89
90 // Finish an AST node, adding `type` and `end` properties.
91

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected