Created
September 8, 2025 08:53
-
-
Save AlexGeb/22a6eddf277ab166295568df229d03c4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable @typescript-eslint/no-explicit-any */ | |
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ( | |
k: infer I, | |
) => void | |
? I | |
: never; | |
export type UnionToTuple<T, R extends any[] = []> = [T] extends [never] | |
? R | |
: UnionToIntersection<T extends any ? (t: T) => void : never> extends ( | |
t: infer U, | |
) => void | |
? UnionToTuple<Exclude<T, U>, [...R, U]> | |
: never; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment