type ArrayPush<T, U> = T extends WritableArray ? _IfNotAnyOrNever<T, IfNever<U, T, [...T, U]>> : never;Adds a new element to the end of a Writable Array type.
| Type Parameter | Description |
|---|---|
|
|
The |
|
|
The element type to add to the |
A new Array type with the element U added to the end.
type Pushed = ArrayPush<[string, number], boolean>; // [string, number, boolean]
type Same = ArrayPush<[string, number], never>; // [string, number]
type Never1 = ArrayPush<readonly [string, number], string> // never
type Never2 = ArrayPush<any, string> // never