Skip to content
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

Support generic state #2982

Closed
parloti opened this issue Apr 1, 2021 · 2 comments · Fixed by #2996
Closed

Support generic state #2982

parloti opened this issue Apr 1, 2021 · 2 comments · Fixed by #2996
Assignees

Comments

@parloti
Copy link

parloti commented Apr 1, 2021

Since this change pull/2967 Typescript can't compile my reducer based on generic state.

The following error is being generated:
Argument of type '(state: TState, action: object & { type: string; }) => TState' is not assignable to parameter of type 'OnReducer<TState, [ActionCreator<string, Creator<any[], object>>]>'.
Type 'TState' is not assignable to type 'TState extends object ? { [P in keyof TState]: TState[P]; } : TState'.
Type 'object' is not assignable to type 'TState extends object ? { [P in keyof TState]: TState[P]; } : TState'.(2345)

Minimal reproduction of the bug/regression with instructions:

Reproduction in the Typescript playground.

Describe any alternatives/workarounds you're currently using

I am currently casting the state returned by the reducer to 'any'.

Other information:

If accepted, I would be willing to submit a PR for this feature

[ ] Yes (Assistance is provided if you need help submitting a pull request)
[X ] No

@HaanJeroen
Copy link

same here! would be nice to get a solution

@sommcz
Copy link

sommcz commented Apr 8, 2021

same here.. the way i only found is to cast reducer return type manually. solved by downgrade to ^11.0 for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants