-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Previous implementations of Redux reducers using combineReducers broken in 2.4.1 #16795
Comments
This would probably be a result of strict contravariance for callback parameters. |
It may be indeed, although I must admit I still fail to see how it is a 'bug' as described in the paragraph you cite. In any case, it is a pretty significant disaster for those of us using Redux, assuming we want to keep using Typescript also. Thanks for pointing to the paragraph though. |
@weswigham I think this is a valid TypeScript bug. If I change the reducer to |
Fair enough, it does. Let me see if I can extend that approach into our more complex real world scenario. Also, now I'm curious if it has always been the case that your syntax would work. Why was the other more obtuse syntax ('') ever used? Anyway, thanks. |
Well, that works, but the change has to be in the Redux index.d.ts. |
There's already an open PR. |
Yep - found that - I have pulled that down and am testing it. It works well. There's a suggestion for an alternative that I will test today. A big issue is that it's going to be really clunky until they actually get the fix into the Redux distribution. I can get that into my work ok, but rolling it out to my team will be problematic until it's actually part of Redux. |
@jimsugg My reducers/index.ts looks like
Can you help me? Thanks. |
i think this issue can be closed! reduxjs/redux#2467 fixed for me |
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed. |
It is broken again with Typescript 2.6.1 and Redux 3.7.2
and here is error:
It works well if I change Reducer definition in
And my reducer:
|
Confirmed, TS 2.6.1 and redux 3.7.2 with similar setup as @lenguyenthanh mentions |
@jhalborg I created an issue in Redux repository: reduxjs/redux#2709. |
TypeScript Version: 2.4.1
Code
Expected behavior:
No errors. This has been working since Typescript 1.8, and works in 2.3.4.
Actual behavior:
Starting with Typescript 2.4.1, the following error is emitted for the combineReducers call:
Error:(40, 36) TS2345:Argument of type '{ statesById: (state: State1[], action: BsDmBaseAction) => State1[]; allIds: (state: string[], ac...' is not assignable to parameter of type 'ReducersMapObject'.
Property 'statesById' is incompatible with index signature.
Type '(state: State1[], action: BsDmBaseAction) => State1[]' is not assignable to type 'Reducer'.
Types of parameters 'action' and 'action' are incompatible.
Type 'A' is not assignable to type 'BsDmBaseAction'.
Type 'Action' is not assignable to type 'BsDmBaseAction'.
Property 'payload' is missing in type 'Action'.
Notes
I do not see any explanation in the various notes on 'breaking changes' to explain this. There are no weak types here, which was involved in the main 'breaking change' description.
The text was updated successfully, but these errors were encountered: