type UnionToIntersectionFn<U> = (U extends unknown ? (k: () => U) => void : never) extends (k: infer I) => void ? I : never;
type GetUnionLast<U> = UnionToIntersectionFn<U> extends () => infer L ? L : never;
type Prepend<Tuple extends unknown[], First> = [First, ...Tuple];
/**
 * Converts a union of types into a tuple type.
 *
 * For example, `UnionToTuple<"a" | "b" | "c">` becomes `["a", "b", "c"]`.
 */
export type UnionToTuple<Union, _Result extends unknown[] = []> = [Union] extends [never] ? _Result : UnionToTuple<Exclude<Union, GetUnionLast<Union>>, // Process the Union excluding its "last" identified element.
Prepend<_Result, GetUnionLast<Union>>>;
export {};
