I am using combineReducers
in my React TypeScript app:
// combinedReducer.ts
import { combineReducers } from \'redux\'
import reducer1 from \'./r
Same problem for me using redux 4.0.5 and typescript 4.0.1. Had to write a inferrer myself:
type BaseReducerMap = {
[K in keyof S]: (state: S[K], action: any) => S
}
export type InferRootState, S = any> = {
[K in keyof ReducerMap]: ReturnType
}
Then for your set of reducers (before you combine them)
const reducers = {
login: loginReducer,
chatUsers: chatUsersReducer,
};
const combinedReducer = combineReducers(reducers);
export type State = InferRootState;
Then typescript can successfully infer the type of my State
.
I don't know why it fails in this version.