Created
May 9, 2022 11:49
-
-
Save wirekang/061f70cb07e5603d3070e77b1751034b to your computer and use it in GitHub Desktop.
Typescript type
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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