-
-
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
Possibly incorrect type for createAction
#224
Comments
I think this is due to declaring Using your example, the return type of const oops: WithTypeProperty<"oops", (error: any) => WithPayload<{}, Action<"oops">>> However, if I just change const oops: WithTypeProperty<"oops", (error: boolean) => WithOptional<void, boolean, WithPayload<{}, Action<"oops">>>> Ditto if I use So, something about @phryneas, @Jessidhia , @tvanier : just out of curiosity, any idea why we're hitting that path, and if it can be tightened up? |
Yep, that's looks right! Interestingly, it works find with I think that the issue may be with the |
Yes, Unknown works well there. Will have to catch that as early as possible - maybe I find the time to look into this on the weekend. |
Maybe this for export type PrepareAction<P, M = void, E = void> = (
...args: any[]
) => Omit<WithOptional<M, E, WithPayload<P, Action>>, 'type'> (or something similar using But then you'd probably need to update |
Mh, I think the error is in
Calling this with |
avoids `any` to take the `void` branch fixes reduxjs#224
Could/Should we simplify by restricting This would also helps with this (not obvious imho)
i.e. action is an error if and only if |
Hmm. Could we? Yeah, and I agree that FSA expects that to just be a boolean. That said, strictly speaking changing it now would technically be considered a breaking change and thus require a semver major. Now, realistically, no one's going to care, because it's been out for all of like 3 days and I'd be shocked if anyone's even using that field yet. Still, I'm not sure there's any real benefit to us restricting the type of the |
This sounds like a bug, unfortunately 😢 The base FSA type, at least one that is error-able, is something like |
Hmm. Okay, yeah, in that case I could see an argument for tightening it up. |
Hopefully fixed by #233 . I'll try to put out a 1.0.1 soon (no later than this weekend). |
I don't think that the recently added
error
field is getting included in the type returned bycreateAction
, seeI get an error like property
error
does not exist on typeWithPayload<{}, Action<"oops">>
, but I think that the inferred type should includeWithOptional
?Of course it's also possible that I'm specifying the action type incorrectly!
The text was updated successfully, but these errors were encountered: