Open ChuckJonas opened 6 years ago
Can confirm, with redux 4 types ain’t working.
I can confirm it too.
Since it doesn’t look lile this package is maintained we switched to some custom code - at the end we didn’t need full store semantics in our action tests, but just a working dispatcher and a way to collect dispatched actions
This is probably a problem with the @types/redux-mock-store
package rather than this one. https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/redux-mock-store
That package lists redux@3.6.0
as a dependency and since there were significant type changes between redux@3
and redux@4
new types will need to be submitted to DefinitelyTyped that are compatible with redux@4
Just submitted this update which should allow you to add the ThunkDispatch signature when creating the store: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/26732
When that is merged and released you can do something like:
const middlewares: Array<Middleware> = [thunk]
type DispatchExts = ThunkDispatch<RootState, undefined, AnyAction>
const mockStoreCreator: MockStoreCreator<RootState, DispatchExts> =
createMockStore<RootState, DispatchExts>(middlewares)
const store: MockStoreEnhanced<RootState, DispatchExts> = mockStoreCreator({})
@chungnho Thank you sir. Took me 5 hours to find this.
👍 to put this in the docs
I made a TypeScript fork of this library and resolved some open issues at @jedmao/redux-mock-store
.
If I load you async example into a project, i get the following error on
return store.dispatch(fetchData())
Using Redux 4.0