I am trying to infer the type of RootState but I get this error, when trying to use it in a selector:
const tagsSelector = (state: RootState) => state.tags;
TS2339: Property 'tags' does not exist on type 'CombinedState<{ tags: CombinedState<{ tagsSet: TagsState; }>; } | { queue: CombinedState<{ clientCard: ClientCardState; clientCardTasks: ClientCardTasksState; }>; }>'. Property 'tags' does not exist on type '{ readonly [$CombinedState]?: undefined; } & { queue: CombinedState<{ clientCard: ClientCardState; clientCardTasks: ClientCardTasksState; }>; }'.
RootState type I infer that
const typedReducers = typedModules.map(m => m.getTypedReducers() ).reduce((accum, r) => {
return {...accum, ...r}
});
const rootTypedReducers = combineReducers(typedReducers);
export type RootState = ReturnType<typeof rootTypedReducers>;
getTypedReducers() just return root reducer of each module
getTypedReducers() {
return {tags: combineReducers({
tagsSet: tagsReducers,
})};
}
However, if I only use one module, then everything works.