Last active
January 8, 2022 21:05
-
-
Save gabiseabra/151799d2942be4063111450a040e6cd7 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 Ix = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | |
| type KVMap<T extends { k: string, v: any }> = { | |
| [k in T['k']]: Extract<T, { k: k }>['v'] | |
| } | |
| type ZipKVMap<K extends string[], V extends any[]> = { | |
| [ix in Ix] | |
| : K[ix] extends string | |
| ? V[ix] extends infer T | |
| ? { k: K[ix], v: T } | |
| : never | |
| : never | |
| }[Ix] | |
| type ZipMap<K extends string[], V extends any[]> = KVMap<ZipKVMap<K, V>> | |
| type T = ZipMap<["a", "b"], [string, number]> // T = { a: string, b: number } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment