import { UnionToIntersection } from "type-fest"; type LastOf = UnionToIntersection T : never> extends () => (infer R) ? R : never type Push = [...T, V]; /** * Union to tuple, but You can't rely on the ordering of a union type. * It's an implementation detail of the compiler; * since X | Y is equivalent to Y | X, the compiler feels free to change one to the other. * @example * ```typescript * type abc = 'a' | 'b' | 'c'; * type t = TuplifyUnion; // ["a", "b", "c"] * ``` */ export type TuplifyUnion, N = [T] extends [never] ? true : false> = true extends N ? [] : Push>, L>