Unpack Array

Get the T from T[] in TypeScript.

type Unpacked<T> = T extends (infer U)[] ? U : T;

type List = string[];
type Item = Unpacked<List>; // string
Last Updated February 23, 2021