You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following wrapper code works in 2.6.0, but fails in 2.6.1
exporttypeAppDispatch=typeofstore.dispatch;exportconstdispatchAndHandleResult=async<Returned,// The type of the return value of the thunkThunkArg// The type of the argument the thunk receives>(dispatch: AppDispatch,action: AsyncThunk<Returned,ThunkArg,{state: RootState;dispatch: AppDispatch;rejectValue: string}>,args: ThunkArg,onSuccess?: (result: Returned)=>void,onFailure?: (error?: string)=>void)=>{constactionResult=awaitdispatch(action(args));if(isFulfilled(actionResult)){if(onSuccess)onSuccess(actionResult.payload);}elseif(isRejected(actionResult)){if(onFailure)onFailure(actionResult.payload);}};
The reported problem from args in await dispatch(action(args));
TS2345: Argument of type 'ThunkArg' is not assignable to parameter of type 'ThunkArg & undefined'.
Type 'ThunkArg' is not assignable to type 'undefined'.
The text was updated successfully, but these errors were encountered:
MrMamen
changed the title
Typescript fail wiht ThunkArk
Typescript fail with ThunkArg
Mar 10, 2025
The following wrapper code works in 2.6.0, but fails in 2.6.1
The reported problem from
args
inawait dispatch(action(args));
The text was updated successfully, but these errors were encountered: