Ensure our readonly emptyArray stays non modified.

This commit is contained in:
Sheetal Nandi 2018-02-26 13:52:09 -08:00
parent a20a00e222
commit a0cd8d3f7d

View File

@ -24,14 +24,14 @@ namespace ts {
* Make `elements` into a `NodeArray<T>`. If `elements` is `undefined`, returns an empty `NodeArray<T>`.
*/
export function createNodeArray<T extends Node>(elements?: ReadonlyArray<T>, hasTrailingComma?: boolean): NodeArray<T> {
if (elements) {
if (!elements || elements === emptyArray) {
elements = [];
}
else {
if (isNodeArray(elements)) {
return elements;
}
}
else {
elements = [];
}
const array = <NodeArray<T>>elements;
array.pos = -1;