-
-
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
Tighten applyMiddleware types #3766
Conversation
Deploy preview for redux-docs ready! Built with commit febd0e1 |
This was the only usage of |
Can we leave the |
Wow, that's a lot of historical context to dig through. However, I still think we should get rid of the I'll start with #1302 since that seems like the most authoritative reasoning. The first problem is that in the example given, the enhancers are applied in the wrong order and should actually be flipped to be like this instead:
This will apply The main issue I have is that enhancers are not expected to pass along an enhancer as their third argument. The above example is the only pattern that will work when mixing enhancer creation styles (i.e., I think the other issues mentioned actually bolster my claim. All of the issues that were linked to in the description of the issue you linked to (#2028, #2128, #2131, #2200) all agree with this change and would not have been created if this change were applied. As a newcomer to the code I found the signature of |
Given that we're looking at doing this all in a v5.0 major anyway, I'd be fine with dropping whatever vague bits of support exist for that legacy syntax. |
Yeah, let's just do this. |
name: "Tighten applyMiddleware types"
about: More correctly types applyMiddleware
PR Type
Does this PR add a new feature, or fix a bug?
Fixes types
Why should this PR be included?
The
applyMiddleware
enhancer should not be allowed to accept any arguments, since it is only guaranteed to acceptpreloadedState?
as its second argument.Also the
createStore
parameter should not beStoreCreator
since it doesn't allow for enhancers. It should match the parameter type forStoreEnhancor
.Checklist
Bug Fixes
What is the current behavior, and the steps to reproduce the issue?
It's implied that more than 2 arguments are accepted by this enhancer, when it should it only be called with 2 arguments.
What is the expected behavior?
TypeScript should produce an error if trying to pass more than the two defined arguments.
How does this PR fix the problem?
It tightens the arguments' types.