语法记录
keyof 与 in
export type ReducersMapObject<S = any, A extends Action = Action> = {
[K in keyof S]: Reducer<S[K], A>
}
Never(nothing) 与 unknown(all)
T | never ⇒ T
T & unknown ⇒ T
三目结合 nerver 做校验
type StateFromReducersMapObject<M> = M extends ReducersMapObject
? { [P in keyof M]: M[P] extends Reducer<infer S, any> ? S : never }
: never
infer: 推测三方的类型
type PromiseReturnType<T> = T extends Promise<infer Return> ? Return : T
type t = PromiseReturnType<Promise<string>> // string
一些好用的
type A = typeof B;
type A = ReturnType<typeof Fn>;
type A = {
[K in keyof S]: B;
}