Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 用typescript重读thunk_Reactjs_Typescript_Redux_Redux Thunk - Fatal编程技术网

Reactjs 用typescript重读thunk

Reactjs 用typescript重读thunk,reactjs,typescript,redux,redux-thunk,Reactjs,Typescript,Redux,Redux Thunk,我正在尝试学习redux,并尝试实现redux-thunk中间件。我一直在关注一些不同的教程,它们提出了类似的建议: import thunk from "redux-thunk"; import promise from "redux-promise-middleware"; ... const middleware = applyMiddleware(promise(), thunk); const store = createStore(reducers, middleware); 这给

我正在尝试学习redux,并尝试实现
redux-thunk
中间件。我一直在关注一些不同的教程,它们提出了类似的建议:

import thunk from "redux-thunk";
import promise from "redux-promise-middleware";
...
const middleware = applyMiddleware(promise(), thunk);
const store = createStore(reducers, middleware);
这给了我以下错误:

/用户/me/Documents/workspace/redux/node_模块/redux thunk/index.d.ts (4,47):泛型类型“Dispatch”需要2个类型参数

有人能解释一下发生了什么以及如何解决这个问题吗


非常感谢

我想您需要以某种方式键入
dispatch

interface IStoreState {
  readonly pendingActions: number;
  readonly isAuthenticated: boolean;
};

function signIn(): (dispatch: Dispatch<IStoreState>) =>  ....
接口{
只读挂起操作:编号;
只读未验证:布尔值;
};
函数signIn():(分派:分派)=>。。。。

.

这个问题与新版本的redux(4.0.0)与当前版本的redux thunk(2.2.0)不兼容有关

请参阅此链接:

这个公关: