-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
createSlice actions TypeScript typings for the payload does not have Intellisense support #426
Comments
I guess you have Please see this answer |
It's turned off by default and turning it on does indeed fix the issue. Closing the issue |
Every |
Hey @RPDeshaies, I put in a PR that might improve the autocompletion for people with
|
I'll check it out today! |
This works like a charm @phryneas |
Context
When using the
createSlice
api with Typescript, it generates actions that can be called using two overloadspayload?: undefined
<PT extends MY_PAYLOAD>(payload?: PT)
whereMY_PAYLOAD
would be the typing provided inside thePayloadAction
of the reducerI have the impression that because of that, Typescript is not able to generate the autocomplete properly even though it is still able to validate the object.
Example
The error message you get is
Which is perfect, but if you try to toggle the intellisense inside the anonymous object of the second call to
setFoo
you get this:Expected behavior
We should be able to see that the only property the payload can receive is
foo: number
Versions
The text was updated successfully, but these errors were encountered: