liuwenjun
liuwenjun
``` type loop = U['length'] extends T ? U : loop type Add = [...loop, ...loop]['length'] // 你的实现代码 type A0 = Add; // 10 type A1 = Add // 28...
``` type Person = { id: string; name: string; age: number; from?: string; speak?: string; }; type OptionalKeys = keyof { [P in keyof T as undefined extends T[P] ?...
``` type Readonly = { readonly [P in keyof T] -?: T[P] } type RequireAllOrNone = Readonly & Omit ···
``` type Flat = T['length'] extends 0 ? U : T extends [infer X, ...infer B] ? (X extends [infer D, ...infer E] ? Flat : Flat ) : U...
``` Likewise, multiple candidates for the same type variable in contra-variant positions causes an intersection type to be inferred: type Bar = T extends { a: (x: infer U) =>...