Skip to content

Instantly share code, notes, and snippets.

// Don't ask about this one. I have no idea what this magic is.
// Copied from https://github.com/microsoft/TypeScript/issues/13298#issuecomment-724542300.
type UnionToIntersection<U> = (
U extends any ? (arg: U) => any : never
) extends (arg: infer I) => void
? I
: never;
// Continuation of above.
type UnionToTuple<T> = UnionToIntersection<(T extends any ? (t: T) => T : never)> extends (_: any) => infer W