Closed mrkswrnr closed 5 years ago
Thanks for bringing this to my attention, working on it.
Also, I chose this approach because when you're invoking an action/commit it might not have a payload, so to require one would be silly. I'll see if I can get proper payload existence detection working, and if possible I can get this working properly.
Thank you for working on it!
Also, I chose this approach because when you're invoking an action/commit it might not have a payload, so to require one would be silly.
I understand. I tried to come up with a conditional type that casts the payload parameter to void/undefined but while Typescript accepts omitting void/undefined parameters when declaring them directly, this does not seems to be working when using conditional types.
If there is no way to omit the parameter I would prefer to be forced to use an empty object as parameter instead of not being able to use object destructuring. But of course this is your decision as a module author.
Resolved with v1.0.2
The definition of ActionHandler marks payload as optional. This makes payload destructuring harder.
Why did you choose this approach?
Example: