Skip to content

Latest commit

 

History

History
43 lines (31 loc) · 670 Bytes

File metadata and controls

43 lines (31 loc) · 670 Bytes

typelab / utils / ExtractArray

type ExtractArray<T> = T extends ReadonlyArray<infer U> ? U : never;

Extract the value type from an Array type.

Type Parameters

Type Parameter Description

T extends ReadonlyArray

The input type which should be an Array.

Returns

The type of the elements in the Array, or never if T is not an Array.

Example

type Valid = ExtractArray<number[]>; // number
type Invalid = ExtractArray<Promise<number>> // never