Max*_*Max 5 reactjs flowtype redux flow-typed
我在应用程序中有两个减速器,结合了减速器(reducer.js).
import { combineReducers } from 'redux';
export const reducers = {
search: searchReducer,
table: tableReducer
};
export const reducer = combineReducer(reducers);
Run Code Online (Sandbox Code Playgroud)
此外,我还有一个代码片段,可以使用来自flow-typed redux_v3.xxjs的Store 自动解析reducers(来自此Medium帖子)的商店类型
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>;
Run Code Online (Sandbox Code Playgroud)
我从流式类型的CombinedReducer得到一个错误,它找不到reducers(搜索和表).
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
Run Code Online (Sandbox Code Playgroud)
如何解决该错误并使我的商店正常使用Flow?
在那个错误之前我得到了另一个
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
Run Code Online (Sandbox Code Playgroud)
我已经添加了Object类型来声明类型CombinedReducer(实际上我不认为我应该编辑flow-typed而在Medium示例中没有这样的错误):
declare type CombinedReducer<S, A> = (state: $Shape<S> & {} | Object | void
Run Code Online (Sandbox Code Playgroud)
我想这些错误可能是由同一件事引起的.
| 归档时间: |
|
| 查看次数: |
1140 次 |
| 最近记录: |