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
On effects, this.reducer() is not correctly infered #870
Comments
I'm happy to take a look at this :) |
It's really tough to figure it out really... Do you have any ideas what might be causing that? |
Actually this type: export type ModelEffect<
TModels extends Models<TModels> = Record<string, any>
> = (
payload: Action['payload'],
rootState: RematchRootState<TModels>,
meta: Action['meta']
) => any Is the current type for an effect, you will see that if you add the export type ModelEffect<
TModels extends Models<TModels> = Record<string, any>
> = (
this: RematchRootState<TModels>
payload: Action['payload'],
rootState: RematchRootState<TModels>,
meta: Action['meta']
) => any We must add something like: It is not an easy fix, @tianzhich it's an expert with types and made something impossible to practically any library out there, is that being practically 100% compatible with the current Redux and React Redux typings. |
Awesome, thanks for explanation, I'll give it another go :) |
I have another question :) I'm not sure if I'm using the correct local examples to actually confirm my changes in the core? is it just the |
Yes the examples folder is linked via the monorepo.
In the root of the project and will rebuild in less than 5 seconds the package =) |
We're using |
Wow, that was a quick response :D Thanks a lot :) |
Hi mate, how about the progress of this? @maciekgrzybek I can continue from your work if you did some modifications. |
Hey @tianzhich I totally dropped the ball on this one, I had few approaches but couldn't figure it out at all :( |
I created a minimal rematch typing system and tried to fix this but failed. Maybe someone can pick this one and continue from here. |
Close this, since will be fixed with 2.1.0 release |
Did this issue fixed ? i'm still not getting correct typing on |
It is partially, we couldn’t fix a 100% type checking it shouldn’t return error at least. Contributions are appreciated ;) |
Describe the bug
With Rematch you can use
this
inside effects to dispatch data to reducers.Basically this:
is equivalent to this:
To Reproduce
When using Typescript, this.SET_PLAYERS() won't get autocompleted because this isn't overriden by Rematch.
Current work around
Expected behavior
Should autocomplete reducers and effects of the current Model.
Additional context
The text was updated successfully, but these errors were encountered: