From cbdf02f47c1af41a985c970d50c942d3c996dcdb Mon Sep 17 00:00:00 2001 From: Andy Date: Mon, 5 Jun 2017 18:07:55 -0700 Subject: [PATCH] Undo change and go back to making a copy of leadingComments and trailingComments (#16273) --- src/compiler/factory.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index a83f00ce86ebc..12e8110e7bec4 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -2503,8 +2503,9 @@ namespace ts { helpers } = sourceEmitNode; if (!destEmitNode) destEmitNode = {}; - if (leadingComments) destEmitNode.leadingComments = concatenate(leadingComments, destEmitNode.leadingComments); - if (trailingComments) destEmitNode.trailingComments = concatenate(trailingComments, destEmitNode.trailingComments); + // We are using `.slice()` here in case `destEmitNode.leadingComments` is pushed to later. + if (leadingComments) destEmitNode.leadingComments = addRange(leadingComments.slice(), destEmitNode.leadingComments); + if (trailingComments) destEmitNode.trailingComments = addRange(trailingComments.slice(), destEmitNode.trailingComments); if (flags) destEmitNode.flags = flags; if (commentRange) destEmitNode.commentRange = commentRange; if (sourceMapRange) destEmitNode.sourceMapRange = sourceMapRange;