mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-10 01:43:59 -05:00
Don't clobber the position of cloned nodes
This commit is contained in:
@@ -1349,15 +1349,16 @@ namespace ts {
|
||||
const visited = visitEachChild(node, getSynthesizedDeepClone, nullTransformationContext);
|
||||
if (visited === node) {
|
||||
// This only happens for leaf nodes - internal nodes always see their children change.
|
||||
return getSynthesizedClone(node);
|
||||
const clone = getSynthesizedClone(node);
|
||||
clone.pos = node.pos;
|
||||
clone.end = node.end;
|
||||
return clone;
|
||||
}
|
||||
|
||||
// PERF: As an optimization, rather than calling getSynthesizedClone, we'll update
|
||||
// the new node created by visitEachChild with the extra changes getSynthesizedClone
|
||||
// would have made.
|
||||
|
||||
visited.pos = -1;
|
||||
visited.end = -1;
|
||||
visited.parent = undefined;
|
||||
|
||||
return visited;
|
||||
|
||||
Reference in New Issue
Block a user