Skip to content

Instantly share code, notes, and snippets.

@nielk
Created April 13, 2023 14:38
Show Gist options
  • Save nielk/9fb33eaa053faeed42310a8cd53c79c0 to your computer and use it in GitHub Desktop.
Save nielk/9fb33eaa053faeed42310a8cd53c79c0 to your computer and use it in GitHub Desktop.
const obj = {
'a': (a: string, b: number): string => `${a}: ${b}`,
'b': (b: number): string => `${b}`,
'c': (): string => 'c',
}
const getFn = <K extends keyof typeof obj>(key: K) => {
return obj[key]
}
getFn('a')('a', 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment