Skip to content

Instantly share code, notes, and snippets.

@shnam7
Created February 29, 2020 05:37
Show Gist options
  • Select an option

  • Save shnam7/702bc3b84ea6a4e2c641be09bf4ac857 to your computer and use it in GitHub Desktop.

Select an option

Save shnam7/702bc3b84ea6a4e2c641be09bf4ac857 to your computer and use it in GitHub Desktop.
Typescript pick() function
/** pick */
export function pick<T, K extends keyof T>(obj: T, ...keys: K[]): Pick<T, K> {
const ret: any = {};
keys.forEach(key => { ret[key] = obj[key]; });
return ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment