Is there any way to correctly dispatch a Thunk from a store created with redux-mock-store ? Right now I am forced to use any type assertion
store.dispatch<any>(getCommissions());
As dispatch
expects to provide plain Action
[ts]
Argument of type '(dispatch: ThunkDispatch<IRootState, undefined,
AnyAction>, getState: () => IRootState) => void' is not assignable to parameter of type 'AnyAction'.
Property 'type' is missing in type '(dispatch: ThunkDispatch<IRootState, undefined, AnyAction>, getState: () => IRootState) => void'.
Code fragment for getCommisions()
export function getCommissions() {
return (dispatch: ThunkDispatch<IRootState, undefined, AnyAction>, getState: () => IRootState) => { ... }
In a similar situation I found a more up to date fork of the library written in Typescript and works better with latest versions of the redux (
4.0.4
) and redux-thunk2.3.0
.https://github.com/jedmao/redux-mock-store