Skip to content

Instantly share code, notes, and snippets.

@Tolluset
Created April 2, 2021 02:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tolluset/7a53fb2ff792127240420d1e1f4de6af to your computer and use it in GitHub Desktop.
Save Tolluset/7a53fb2ff792127240420d1e1f4de6af to your computer and use it in GitHub Desktop.
Get values using generic
const getValue = <T, U extends keyof T>(obj: T, key: U): T[U] => {
return obj[key];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment