Skip to content

Commit eb4f067

Browse files
committed
Don't clobber the position of cloned nodes
1 parent 18afd8a commit eb4f067

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/services/utilities.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,15 +1349,16 @@ namespace ts {
13491349
const visited = visitEachChild(node, getSynthesizedDeepClone, nullTransformationContext);
13501350
if (visited === node) {
13511351
// This only happens for leaf nodes - internal nodes always see their children change.
1352-
return getSynthesizedClone(node);
1352+
const clone = getSynthesizedClone(node);
1353+
clone.pos = node.pos;
1354+
clone.end = node.end;
1355+
return clone;
13531356
}
13541357

13551358
// PERF: As an optimization, rather than calling getSynthesizedClone, we'll update
13561359
// the new node created by visitEachChild with the extra changes getSynthesizedClone
13571360
// would have made.
13581361

1359-
visited.pos = -1;
1360-
visited.end = -1;
13611362
visited.parent = undefined;
13621363

13631364
return visited;

0 commit comments

Comments
 (0)