我想检索函数的第一个参数类型。我试图通过类似于文档中的ExtractReturnType函数来创建一个ExtractArgType类型,但是出了点问题:
type InputFunction = ({arg: number}) => void
type ExtractArgType = <A>((A) => any) => A
type ArgType = $Call<ExtractArgType, InputFunction>
const bar: ArgType = "not ok" // should say - Hey, ArgType is a number
还提供ExtractReturnType进行比较:
type ExtractReturnType = <V>(() => V) => V