Ts体操--Parameters
zhuba-Ahhh opened this issue · 0 comments
zhuba-Ahhh commented
实现内置的 Parameters 类型,而不是直接使用它,可参考TypeScript官方文档。
type MyParameters<T extends (...args: any[]) => any> = T extends (
...args: infer P
) => any
? P
: never;
// infer
const foo = (arg1: string, arg2: number): void => {}
type FunctionParamsType = MyParameters<typeof foo> // [arg1: string, arg2: number]