Created
May 8, 2020 13:29
-
-
Save fend25/6288aabd0065ac3b4d6492b34ef4949d to your computer and use it in GitHub Desktop.
Typescript. Typed versions of Object.keys, Object.values, Object.entries
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
export const getKeys = <T extends Object>(o: T) => Object.keys(o) as Array<keyof T> | |
export const getValues = <T extends Object>(o: T) => Object.values(o) as Array<T[keyof T]> | |
export const getEntries = <T extends Object>(o: T) => Object.entries(o) as Array<[keyof T, T[keyof T]]> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment