I ran into an issue and received the following error message:
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* :
*
The declaration code is as follows:
export interface Action<T = any> {
type: T
}
The AnyAction extends the Action interface.
This snippet shows my test code:
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()); //this line triggers the error
The definition of the signIn
function is as follows:
export const signIn = () =>
async (dispatch: Dispatch): Promise<void> => {
dispatch({
type: SIGN_IN_REQUEST
});
};
Does anyone have a suggestion or idea on how to resolve this issue?