I've got two reducers in the app combined with combine reducer (reducer.js).
import { combineReducers } from 'redux';
export const reducers = {
search: searchReducer,
table: tableReducer
};
export const reducer = combineReducer(reducers);
Also I have a snippet to automatically parse store types from reducers (from this Medium post) using Store from flow-typed redux_v3.x.x.js
import { reducers } from './reducer';
type Reducers = typeof reducers;
type $ExtractFunctionReturn = <V>(v: (...args: any) => V) => V;
export type State = $ObjMap<Reducers, $ExtractFunctionReturn>;
export type Store = ReduxStore<State, Actions>;
And I got an error from flow-typed CombinedReducer that it can't find reducers (search and table).
src/types.js:65
65: export type Store = ReduxStore<State, Actions>;
^^^^^ property `search`. Property not
found in
54: declare function combineReducers<O: Object, A>(reducers: O):
CombinedReducer<$ObjMap<O, <S>(r: Reducer<S, any>) => S>, A>;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ object type. See lib: flow-
typed/npm/redux_v3.x.x.js:54
src/types.js:65
65: export type Store = ReduxStore<State, Actions>;
^^^^^ property `table`. Property not
found in
54: declare function combineReducers<O: Object, A>(reducers: O):
CombinedReducer<$ObjMap<O, <S>(r: Reducer<S, any>) => S>, A>;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ object type. See lib: flow-
typed/npm/redux_v3.x.x.js:54
How to solve that error and make my Store working correct with Flow?
Before that error I got another one
Flow: object map. This type is incompatible with union: Intersection
type | undefined.
flow-typed/redux_v3.x.x.js
30: declare type CombinedReducer<S, A> = (state: $Shape<S> & {} | void
And I have added Object type to declare type CombinedReducer (actually I don't think I should edit flow-typed and in the Medium example there is no such an error):
declare type CombinedReducer<S, A> = (state: $Shape<S> & {} | Object | void
I suppose these errors can be caused by the same thing.