UNPKG

@cuppachino/type-space

Version:

A collection of type utilities for TypeScript.

10 lines (9 loc) 265 B
/** * Split a string literal into an tuple of characters. * * @example * ``` * type MyChars = Chars<'abc'> // ['a', 'b', 'c'] * ``` */ export type Chars<S extends string, A extends string[] = []> = S extends `${infer C}${infer R}` ? Chars<R, [...A, C]> : A;