带有打字稿的 redux-thunk [英] redux-thunk with typescript
问题描述
我正在尝试学习 redux 并且我正在尝试实现 redux-thunk
中间件.我一直在关注一些不同的教程,他们提出了类似的建议:
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);
这给了我以下错误:
/Users/me/Documents/workspace/redux/node_modules/redux-thunk/index.d.ts(4,47):通用类型Dispatch"需要 2 个类型参数.
/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?
非常感谢
推荐答案
这个问题原来是因为新版本的 redux (4.0.0) 与当前版本的 redux-thunk (2.2.0) 不兼容.
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).
请参阅此链接:https://github.com/gaearon/redux-thunk/issues/169
和这个公关:https://github.com/gaearon/redux-thunk/pull/180
这篇关于带有打字稿的 redux-thunk的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!