TypeScript infer keyword All In One
Conditional Types / 条件类型
infer keyword
https://www.typescriptlang.org/docs/handbook/type-inference.html
https://www.cnblogs.com/xgqfrms/tag/infer/
demos
// Here we declare a new type variable `R` in MyType, which gets `inferred` from `T`.
type MyType<T> = T extends infer R ? R : never;
type T1 = MyType<{b: string}>
// T1 is { b: string; }
refs
TypeScript 协变与逆变 All In One
https://www.cnblogs.com/xgqfrms/p/16200884.html
https://stackoverflow.com/questions/60067100/why-is-the-infer-keyword-needed-in-typescript
https://blog.logrocket.com/understanding-infer-typescript/
https://levelup.gitconnected.com/using-typescript-infer-like-a-pro-f30ab8ab41c7
https://www.tutorialsteacher.com/typescript/type-inference
©xgqfrms 2012-2021
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 ️,侵权必究⚠️!