From c154b81986ad32d20ae1d8aaefe5126776c933bf Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 26 Feb 2018 13:52:09 -0800 Subject: [PATCH] Ensure our readonly emptyArray stays non modified. --- src/compiler/factory.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 92d353aeb0efa..af26ad8337ad8 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -24,14 +24,14 @@ namespace ts { * Make `elements` into a `NodeArray`. If `elements` is `undefined`, returns an empty `NodeArray`. */ export function createNodeArray(elements?: ReadonlyArray, hasTrailingComma?: boolean): NodeArray { - if (elements) { + if (!elements || elements === emptyArray) { + elements = []; + } + else { if (isNodeArray(elements)) { return elements; } } - else { - elements = []; - } const array = >elements; array.pos = -1;