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

Effect type inference error on typescript 4.9 #986

Open
otaviosoares opened this issue Oct 4, 2023 · 0 comments
Open

Effect type inference error on typescript 4.9 #986

otaviosoares opened this issue Oct 4, 2023 · 0 comments

Comments

@otaviosoares
Copy link

Type inference for effects fails when payload and rootState are optional. It can be observed in here:

dispatch.count.incrementEffect(2)
dispatch.count.incrementEffect()

Reproduce Link

https://codesandbox.io/s/rematch-ts-4-9-error-w4sz3r

To Reproduce

Use typescript 4.9+

Expected behavior

I should correctly infer the effect type.

Additional context

Not sure if this is a rematch or typescript bug. I was debugged the types in rematch and tracked it down to type ExtractRematchDispatcherFromEffect on this line

> = TEffect extends (...args: infer TRest) => infer TReturn

The effect function with optional args is not matching (...args: infer TRest) so it infers to never.

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

No branches or pull requests

1 participant