Skip to content

Instantly share code, notes, and snippets.

@tolluset
Created April 2, 2021 02:41
Show Gist options
  • 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