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

Function cloneIdentifier

packages/babel-parser/src/parser/node.ts:192–206  ·  view source on GitHub ↗
(node: T)

Source from the content-addressed store, hash-verified

190 }
191
192 cloneIdentifier<T extends Identifier | Placeholder>(node: T): T {
193 // We don't need to clone `typeAnnotations` and `optional`: because
194 // cloneIdentifier is only used in object shorthand and named import/export.
195 // Neither of them allow type annotations after the identifier or optional identifier
196 const { type, start, end, loc, range, name } = node;
197 const cloned = Object.create(NodePrototype);
198 cloned.type = type;
199 cloned.start = start;
200 cloned.end = end;
201 cloned.loc = loc;
202 cloned.range = range;
203 cloned.name = name;
204 if (node.extra) cloned.extra = node.extra;
205 return cloned;
206 }
207
208 cloneStringLiteral<T extends StringLiteral | EstreeLiteral | Placeholder>(
209 node: T,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected