Type Alias: ArrayElementType<T>
ArrayElementType<
T
>:T
extends infer K[] ?K
:T
extends readonly infer RK[] ?RK
:T
Gets a union type of all the keys that are in an array.
Type Parameters
Type Parameter |
---|
T |
Example
const sample = [1, 2, '3', true];
type arrayUnion = ArrayElementType<typeof sample>;
// Expected: string | number | boolean