Daily-Question
Daily-Question copied to clipboard
【Q707】请简述 typescript 中的 infer
和returnType有点关联,做返回值推断的
infer
表示在 extends
条件语句中待推断的类型变量。
例子:
/**
* Obtain the parameters of a function type in a tuple
*/
type Parameters<T extends (...args: any) => any> = T extends (...args: infer P) => any ? P : never;