Skip to content

Commit

Permalink
Ensure our readonly emptyArray stays non modified.
Browse files Browse the repository at this point in the history
  • Loading branch information
sheetalkamat committed Feb 26, 2018
1 parent 4f1640d commit c154b81
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/compiler/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c154b81

Please sign in to comment.