Property 'type' is missing in type 'AsyncThunkAction<TicketEntity[], void, {}>' but required in type 'AnyAction'.
TS2345: Argument of type 'AsyncThunkAction<TicketEntity[], void, {}>' is not assignable to parameter of type 'AnyAction'. Property 'type' is missing in type 'AsyncThunkAction<TicketEntity[], void, {}>' but required in type 'AnyAction'.
"@reduxjs/toolkit": "1.7.1",
"react": "17.0.2",
"react-redux": "7.2.6",
store.ts
export const store = configureStore({
reducer: {
[EntityStoreName.Oem]: oemReducer,
[EntityStoreName.Ccvs]: ccvsState.reducer,
[EntityStoreName.CloudConnections]: cloudConnectionsState.reducer,
[EntityStoreName.ChangeRequests]: changeRequestsState.reducer,
[EntityStoreName.Locations]: locationsState.reducer,
[EntityStoreName.Organizations]: organizationsReducer,
[EntityStoreName.Tickets]: ticketsState.reducer,
[EntityStoreName.TicketComments]: ticketCommentsState.reducer,
[EntityStoreName.TicketAttachments]: ticketAttachmentsState.reducer,
[StoreName.Session]: sessionReducer,
[StoreName.Modal]: modalState.reducer,
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware({
serializableCheck: {
ignoredActions: [FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER],
export const persistor = persistStore(store);
export type AppState = ReturnType<typeof store.getState>;
repository.ts
export const getTicketsList = createAsyncThunk(
`${EntityStoreName.Tickets}/getList`,
(_, { signal }): Promise<TicketEntity[]> => {
const cancelToken = cancelationSubscribe(signal);
return apiRequestCall<TicketEntity[]>({
params: {
method: 'GET',
apiVersion: ApiVersion.V1,
resource: ApiResource.Tickets,
cancelToken,
Type issue:
Most likely you have two conflicting versions of redux
somewhere in your node_modules
. 4.0.x
and 4.1.x
are not compatible on a type level (and generally you should only have one redux version).
You can search those with npm ls redux
or yarn why redux
.
@phryneas I forgot the "no".. sorry
it seems that it happens because of a typescript version:
it's fine with 4.5.5, but with 4.6.2 there is a problem
const reducers = mapValues(registry as Required<typeof registry>, (initFn) => initFn({ subscribeToStoreChange })) as {
[key in keyof RootState]: Reducer<RootState[key], AnyAction>;
const store = configureStore({
reducer: reducers,
preloadedState: initialState,
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware({
serializableCheck: {
ignoredPaths: ['beOverrides'],
ignoredActions: ['beOverrides/overrideApis'],
ok, I have it, actually now it seems a slightly different error..
so maybe it should be a slightly different issue. anyway this is the code
the problem seems to be with the definition of dispatch in the thunkConfig
const store = configureStore({
reducer: { },
type StoreType = typeof store;
type AppDispatch = StoreType['dispatch'];
type Config = {
dispatch: AppDispatch;
const asyncActionFail = createAsyncThunk<any, void, Config>('prefix', () => {
return Promise.resolve([]);
store.dispatch(asyncActionFail()); //this fails
the error is
No overload matches this call.
The last overload gave the following error.
Argument of type 'AsyncThunkAction<any, void, Config>' is not assignable to parameter of type 'AnyAction | ThunkAction<Promise<PayloadAction<any, string, { arg: void; requestId: string; requestStatus: "fulfilled"; }, never> | PayloadAction<unknown, string, { arg: void; requestId: string; requestStatus: "rejected"; aborted: boolean; condition: boolean; } & ({ ...; } | ({ ...; } & {})), SerializedError>> & { .....'.
Type 'AsyncThunkAction<any, void, Config>' is not assignable to type 'ThunkAction<Promise<PayloadAction<any, string, { arg: void; requestId: string; requestStatus: "fulfilled"; }, never> | PayloadAction<unknown, string, { arg: void; requestId: string; requestStatus: "rejected"; aborted: boolean; condition: boolean; } & ({ ...; } | ({ ...; } & {})), SerializedError>> & { ...; }, any, u...'.
Types of parameters 'dispatch' and 'dispatch' are incompatible.
Type 'ThunkDispatch<any, undefined, AnyAction>' is not assignable to type 'Dispatch<AnyAction> & ThunkDispatch<any, null, AnyAction> & ThunkDispatch<any, undefined, AnyAction>'.
Type 'ThunkDispatch<any, undefined, AnyAction>' is not assignable to type 'ThunkDispatch<any, null, AnyAction>'.
Type 'undefined' is not assignable to type 'null'.
on a side note, don't remember why I added the dispatch type there but if I remove it seems to work in both typescript versions.
but it is odd behavior still
@alissaVrk it doesn't seem to fail for me: https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAbwMYQHYDNgHMCuUCmAyjNPgDRxIECGM+AggM4CeqSAKgBY6oDWcAXzjooEEHADkAAQIATHAA8AVowD0JCABtewGBIBQ+lKkbxTpOAF5KaTLgLFSACgT64cOTiT4oALkSCZPoCAJQA3IYwzGD4cI4E7NGx1lExEOhw5gQRqbH0YGAAIsCMYLRInFZxJAlJANoSsiVlMBUSALoR+rlwAMK22FWu7k2l5Zz++UXN4xECXcamcNQsbPRIMMBoAGLUwJpVVPi0DKsc3HwAPNSozBQAbhDAshT9GNgAfE4SYASYChIKE4QlYPog3B58DA8Kg4AAFUQgEr4AB0BEYWnu+CcdXa4WC+P0WVRoxaFScK1YSHWmx2e00wPCcFU6k4JWE9MYQA
Hey there, Just in case, I had the same problem with 8.0.2 and solved it adding the type in the declaration like this:
const dispatch = useDispatch<AppDispatch>();
For me I had defined an AppThunkAction like
export type AppThunkAction<R = void> = ThunkAction<R, RootState, never, Action>
and I kept getting the "Property 'type' is missing in type..." error when trying to dispatch. The problem turned out to be the never
. I changed it to unknown
instead and the error went away.
So now it looks like
export type AppThunkAction<R = void> = ThunkAction<R, RootState, unknown, Action>