type rootState = {
count: typeof countInitialValue;
name: typeof nameInitialValue;
};
type rootAction = CountActionType | NameActionType;
const reducers = combineReducers<rootState, rootAction>({
count: countReducer,
name: nameReducer
});
如果rootAction
写成上面那样错误信息
TS2322:
Type 'Reducer<{ count: number; }, CountActionType>' is not assignable to type 'Reducer<{ count: number; }, rootAction>'.
Types of parameters 'action' and 'action' are incompatible.
Type 'rootAction' is not assignable to type 'CountActionType'.
Type '{ type: "SET_NAME"; name: string; }' is not assignable to type 'CountActionType'.
Type '{ type: "SET_NAME"; name: string; }' is not assignable to type '{ type: "MINUS_NUMBER"; }'.
我看了它的定义,还是没有明白应该怎么写
export type ReducersMapObject<S = any, A extends Action = Action> = {
[K in keyof S]: Reducer<S[K], A>;
};
求助~