mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 21:36:50 -05:00
Ensure our readonly emptyArray stays non modified.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user