学习了很久的ts,感觉还不够深入,在项目中能使用到ts的地方感觉都比较简单,对于ts来讲也就发挥了它一成的功力吧,所以今天就infer类型深入研究一下
先看官方对infer的解释
Within the extends clause of a conditional type, it is now possible to have infer declarations that introduce a type variable to be inferred. Such inferred type variables may be referenced in the true branch of the conditional type. It is possible to have multiple infer locations for the same type variable.
翻译过来就是
在条件类型的extends子句中,现在可以使用infer声明来引入要推断的类型变量。这样的推断类型变量可以在条件类型的真分支中引用。对于同一个类型变量,可以有多个推断位置。
