mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 03:23:08 -06:00
Ensure our readonly emptyArray stays non modified.
This commit is contained in:
parent
a20a00e222
commit
a0cd8d3f7d
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user