Skip to content

Commit 36d0274

Browse files
committed
Ensure our readonly emptyArray stays non modified.
1 parent eb0955c commit 36d0274

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/compiler/factory.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ namespace ts {
2424
* Make `elements` into a `NodeArray<T>`. If `elements` is `undefined`, returns an empty `NodeArray<T>`.
2525
*/
2626
export function createNodeArray<T extends Node>(elements?: ReadonlyArray<T>, hasTrailingComma?: boolean): NodeArray<T> {
27-
if (elements) {
27+
if (!elements || elements === emptyArray) {
28+
elements = [];
29+
}
30+
else {
2831
if (isNodeArray(elements)) {
2932
return elements;
3033
}
3134
}
32-
else {
33-
elements = [];
34-
}
3535

3636
const array = <NodeArray<T>>elements;
3737
array.pos = -1;

0 commit comments

Comments
 (0)