-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
configureStore()
middleware action typings are wrong
#289
Comments
Fascinating, I always assumed that Thank you for bringing that to my attention. @markerikson I guess we should add support for this as well then, shouldn't we? In the meantime, the way to currently work around this is documented in the "Usage with TypeScript" documentation: Extending the Dispatch type |
Thanks for the workaround, although it'd be slightly nicer if it were possible to use the type parameters instead. |
Yeah, definitely be nice if we can fix this. |
@slikts I just finished my work on the PR, so this will most likely make it into the next version of RTK. |
Should be fixed in https://github.com/reduxjs/redux-toolkit/releases/tag/v1.2.2 . |
Currently the
middleware
option forconfigureStore()
does not affect what action typesstore.dispatch()
accepts; thunks are always accepted even if the thunk middleware is missing, and adding other middleware ignores its dispatch signature.This is a regression from Redux, where the dispatchable action types are picked up correctly by
createStore()
.Example:
I've also made a longer working example that defines a number middleware that adds a number action type and shows that the types work with plain Redux but not RTK. I've tried to work around the issue by passing explicit type parameters like so:
configureStore<RootState, AnyAction | number>
, but it doesn't work due to always expecting a type property on the action.The text was updated successfully, but these errors were encountered: