UNPKG

@cuppachino/type-space

Version:

A collection of type utilities for TypeScript.

7 lines (6 loc) 369 B
import type { UnionToIntersection } from './union-to-intersection'; /** * Converts a union type to a tuple type, the order is not guaranteed. * This is useful as an intermediate step for other types. */ export type UnionToTuple<T> = UnionToIntersection<T extends never ? never : (t: T) => T> extends (_: never) => infer W ? [...UnionToTuple<Exclude<T, W>>, W] : [];