-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Fix combineReducers typings. #3679
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
Fix combineReducers typings. #3679
Conversation
Related to reduxjs#2709
Deploy preview for redux-docs ready! Built with commit a54a229 |
Should |
It sounds reasonable to me. I have checked against my local project though and it doesn't improve the type inference in this case. I also see another usage of |
@timdorr I don't want to be "that guy" you know, but is there anything I can do to help getting this merged and released anytime soon? 😉 |
Can confirm that this fixes a regression we experienced recently. Specifically, our thunk dispatch type was conflicting w/ a third party reducer (TS complaining about actions missing Thanks @gilbsgilbs! Erm, edit: Unfortunately this is still conflicting w/ one less property "type" |
Only thing this needs is some tests! |
I guess I'll (finally) merge this in without tests. Thanks! |
PR Type
Does this PR add a new feature, or fix a bug?
Fixes a bug.
Why should this PR be included?
It fixes a typing issue I and some other folks have with the
combineReducers
function: #2709Checklist
Bug Fixes
What is the current behavior, and the steps to reproduce the issue?
Unfortunately, I failed to create a simple reproduction example. Still, it happens that TypeScript would fail to infer the proper generic type to
combineReducers
function. In my case, I'm doing something like this:What is the expected behavior?
I would expect TypeScript to infer a generic type automatically.
How does this PR fix the problem?
It removes explicit
any
s which appears to help TypeScript to infer a type. I'm not sure why though 🤷♂️ . Could this be a bug in TypeScript?More specifically, the first generic type of
ReducersMapObject
is a state which is alreadyany
by default, and the second generic type isA extends Action
which isAction
by default and notany
. So the fact that the second generic type isany
confuses TS for some reason.