type ArrayFirst<T> = T extends ReadonlyArray ? _IfNotAnyOrNever<T, T[0]> : never;Extracts the type of the first element of an Array type.
| Type Parameter | Description |
|---|---|
|
|
The |
The type of the first element from type T.
// string
type FirstElement = ArrayFirst<[string, number, boolean]>;
// string | number | boolean
type AllElements = ArrayFirst<(string | number | boolean)[]>;
// never
type Never = ArrayFirst<any>;