Don't clobber the position of cloned nodes

This commit is contained in:
Andrew Casey
2017-10-11 13:53:52 -07:00
parent 18afd8a50d
commit eb4f067ecb

View File

@@ -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;