-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TS conflict between AppThunk and createAsyncThunk.withTypes #4602
Comments
are you specifically providing |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What docs page needs to be fixed?
In the Redux Docs > Usage With Typescript > Type Checking Redux Thunks, it recommends using the following to type thunks:
In the RTK Docs > Usage with Typescript > Defining a Pre-Typed createAsyncThunk, it recommends the following to type
createAsyncThunk
:I'm using both of these in my apps, but when I try to dispatch a thunk created using
createAppAsyncThunk
from a regular thunk, it's flagging a type error.What is the problem?
From what I can see, it seems the two approaches type
dispatch
differently. The first approach (withAppThunk
) types thedispatch
parameter asThunkDispatch<RootState, unknown, UnknownAction>
but the second approach (withcreateAsyncThunk.withTypes
) types thedispatch
parameter asThunkDispatch<RootState, undefined, UnknownAction>
which is causing a problem,What should be changed to fix the problem?
I was able to fix the problem like this:
The text was updated successfully, but these errors were encountered: