Last active
October 5, 2023 12:24
-
-
Save sagarpanchal/22055b394db18d8c4e3c2aed43ea8075 to your computer and use it in GitHub Desktop.
TS pick/omit
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
function pick<T, K extends keyof T>(obj: T, ...keys: K[]) { | |
return Object.fromEntries(keys.map((key) => [key, obj[key]])) as Pick<T, K> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment