【发布时间】:2021-02-23 01:37:19
【问题描述】:
我遇到了这个错误:
TS2345: Argument of type '(dispatch: Dispatch) => Promise<void>' is not assignable to parameter of
type 'AnyAction'. Property 'type' is missing in type '(dispatch: Dispatch) => Promise<void>' but
required in type 'AnyAction'. type' is declared here* :
*声明代码为:
export interface Action<T = any> {
type: T
}
AnyAction 扩展了 Action。
这是我的测试代码:
import configureStore from 'redux-mock-store';
import reduxThunk from 'redux-thunk';
// some code, then in the test I have:
const mockStore = configureStore([reduxThunk]);
const store = mockStore({});
store.dispatch(signIn()); //here I have the error
signIn的定义是:
export const signIn = () =>
async (dispatch: Dispatch): Promise<void> => {
dispatch({
type: SIGN_IN_REQUEST
});
};
关于如何修复它的任何提示或想法?
【问题讨论】:
标签: typescript redux-thunk react-testing-library