Created
May 28, 2021 10:41
-
-
Save chpio/1f2ee880917322dc7e0769688338c03c to your computer and use it in GitHub Desktop.
Object.fromEntries typescript
This file contains 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
interface ObjectConstructor { | |
fromEntries<T extends readonly [PropertyKey, unknown]>( | |
entries: Iterable<T>, | |
): { [K in T[0]]?: Extract<T, readonly [K, unknown]>[1] }; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Seams to not work properly if there are multiple keys having the same content type, eg:
results in: