Skip to content

Instantly share code, notes, and snippets.

@wirekang
Created May 9, 2022 11:49
Show Gist options
  • Save wirekang/061f70cb07e5603d3070e77b1751034b to your computer and use it in GitHub Desktop.
Save wirekang/061f70cb07e5603d3070e77b1751034b to your computer and use it in GitHub Desktop.
Typescript type
interface I1 {
p1: (a: boolean)=>void
p2: (a: string) => void
p3: (a: number) => void
}
const v1:I1 = 0 as any
function f1<T extends keyof I1>(
name: T,
arg: Parameters<I1[T]>[0]
){
v1[name](arg)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment