我为我的减速器编写了以下代码:
import { Reducer, combineReducers } from 'redux';
import { routerReducer } from 'react-router-redux';
import { firebaseReducer } from 'react-redux-firebase';
import { firestoreReducer } from 'redux-firestore';
const reducers: Reducer<ApplicationState> = combineReducers<ApplicationState>({
firebase: firebaseReducer,
firestore: firestoreReducer,
router: routerReducer
});
export { reducers };我几乎跟随了这里的教程
但是,firestore还原程序发出以下消息:
Argument of type '{ firebase: typeof firebaseReducer; firestore: typeof firestoreReducer; router: Reducer<RouterSta...' is not assignable to parameter of type 'ReducersMapObject'.
Property 'firestore' is incompatible with index signature.
Type 'typeof firestoreReducer' is not assignable to type 'Reducer<any>'.
Type 'typeof firestoreReducer' provides no match for the signature '(state: any, action: AnyAction): any'.问题可能是什么,如何解决?
发布于 2018-03-30 09:28:25
似乎TS正在寻找一个Reducer在firebaseReducer的位置,但发现了其他的东西。为了看“其他东西”是什么,我去看了类型,找到这个,和.立刻感到困惑。看起来这些类型不仅仅是破碎的,它们甚至可能不存在。手工铸造可能是你最好的选择。
const reducers: Reducer<ApplicationState> = combineReducers<ApplicationState>({
firebase: firebaseReducer,
firestore: firestoreReducer as Reducer<ApplicationState>,
router: routerReducer
});我也会考虑打开一个问题或公关的这一点。,这有点令人费解,以前没人遇到过这种情况。
https://stackoverflow.com/questions/49571421
复制相似问题