Redux 动态模块:类型 'AnyAction' 不可分配给类型 'Action'



我正在我的应用程序中实现redux-dynamic-modules,它不是我应用程序中的第一个模块,但是当我尝试创建此模块时出现奇怪的错误:

export const reduxProfile = () => {
return {
id: 'profile',
reducerMap: {
profile: reducer
},
sagas: [profileSagas],
retained: true
}
}
Type 'Reducer<ProfileState, Action>' is not assignable to type 'Reducer<any, AnyAction>'.
Types of parameters 'action' and 'action' are incompatible.
Type 'AnyAction' is not assignable to type 'Action'.
Type 'AnyAction' is not assignable to type 'SetPriceAction'.

这是我的SetPriceAction,看起来不错:

export interface SetPriceAction extends AnyAction {
payload: Result;
type: ActionTypes.SET_PRICE;
}
...
export type Action =
| ...
| SetPriceAction;

在另一个模块中几乎具有相同的形状,并且在那里一切正常。 谁能帮助这里出了什么问题?

快速绕过是将有效负载设置为可选。

export interface SetPriceAction extends AnyAction {
payload?: Result;
type: ActionTypes.SET_PRICE;
}

但我正在积极寻找需要定义有效载荷的长期解决方案。如果我在这件事上取得任何进展,我会让你知道

相关内容

最新更新