Created
June 3, 2024 20:21
-
-
Save fostyfost/c90531ba670c395b905719129c28cd38 to your computer and use it in GitHub Desktop.
Union to tuple
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
export type UnionToTuple<U extends string, R extends any[] = []> = { | |
[S in U]: Exclude<U, S> extends never ? [...R, S] : UnionToTuple<Exclude<U, S>, [...R, S]> | |
}[U] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment