Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

redux-thunk with typescript

I am trying to learn redux and I am trying to implement the redux-thunk middleware. I've been following a few different tutorials and they suggest something similar to this:

import thunk from "redux-thunk";
import promise from "redux-promise-middleware";
...
const middleware = applyMiddleware(promise(), thunk);
const store = createStore(reducers, middleware);

This gives me the following error:

/Users/me/Documents/workspace/redux/node_modules/redux-thunk/index.d.ts (4,47): Generic type 'Dispatch' requires 2 type argument(s).

Can someone please explain what is going on and how to fix this?

Many thanks

like image 924
JT-Helsinki Avatar asked Nov 07 '22 08:11

JT-Helsinki


1 Answers

This problem turns out to be related to the new version of redux (4.0.0) being incompatible with the current version of redux-thunk (2.2.0).

See this link: https://github.com/gaearon/redux-thunk/issues/169

and this PR: https://github.com/gaearon/redux-thunk/pull/180

like image 179
JT-Helsinki Avatar answered Nov 15 '22 04:11

JT-Helsinki