我正在redux thunk中进行文档测试,但是它是在js中,我正在打字稿中实现它,这是我的测试配置:
const middleware = [thunk];
type DispatchExts = ThunkDispatch<AppState, void, AnyAction>;
const mockStore = createMockStore<AppState, DispatchExts>(middleware);
一切正常,直到这里:
return store
.dispatch(actions.fetchTodos({ page: 1, filter: 'All' }))
.then(() => { // <-- .then ERROR HERE
// return of async actions
expect(store.getActions()).toEqual(expectedActions);
});
错误发生在.then上,并说类型'void'不存在'Property'then',这段代码有什么问题?
这样做可以消除错误,我没有使用DispatchExts:
type DispatchExts = ThunkDispatch<AppState, void, AnyAction>;
const mockStore = createMockStore<AppState, any>(middleware);
但我不想使用任何用户。 :(