type ArrayPop<T> = T extends WritableArray ? _IfNotAnyOrNever<T, T extends [...(infer U), Any?] ? U : T> : never;Removes the last element from an Writable Array type.
If the Array is a Tuple, the result will be a new Tuple without the last element.
If the Array is not a Tuple, the result will be the original Array type.
| Type Parameter | Description |
|---|---|
|
|
The |
A new Array type with the last element removed.
type Popped = ArrayPop<[string, number]>; // [string]
type Same = ArrayPop<(string | number)[]>; // (string | number)[]
type Never1 = ArrayPop<readonly [string, number]>; // never
type Never2 = ArrayPop<any>; // never