Skip to content

InferArray<T>

ts
type InferArray<T> = T extends infer U[] ? U : never;

Defined in: types.ts:30

Extracts the element type from an array type.

Type Parameters

Type ParameterDescription
T extends unknown[]The array type to infer from

Example

ts
type Result = InferArray<[string, number, boolean]>;
// Result: string | number | boolean