Created
February 25, 2021 02:09
-
-
Save hrdtbs/de0512f64d4d59cc36bf19e2bc29c04c 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
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never | |
type LastOf<T> = UnionToIntersection<T extends any ? () => T : never> extends () => infer R ? R : never | |
type Tuplify<Union, Flag = [Union] extends [never] ? true : false, Last = LastOf<Union>> = true extends Flag | |
? [] | |
: [...Tuplify<Exclude<Union, Last>>, Last] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment