Closed frango9000 closed 1 year ago
Run & review this pull request in StackBlitz Codeflow.
Oh, sorry I saw your PR after merging the one from @EricPoul
I'd keep an error as it was before. I was able to properly type createAction
with { dispatch: true }
and ts will show an error if you do return not an Action
but if there's { dispatchByDefault: true }
the error is the only way to notify a developer that not an Action
is returned to the dispatcher.
It is ok ๐ But just wondering, if we receive multiple "maybe" actions as we can now, but only one is actually an action, this filtering will throw and the other "maybe actions" which are actually actions won't get dispatched. So it is not actually filtering. It is checking if any "maybe actions" is not an action to not dispatch anything. Or am I missing something?
Yes, it's more like an extra guard that will allow us to know that all "possible" actions are really actions so TS won't complain that we try to dispatch "anything".
But just wondering, if we receive multiple "maybe" actions as we can now, but only one is actually an action, this filtering will throw and the other "maybe actions" which are actually actions won't get dispatched.
Yes. If you made an effect with { dispatch: true }
or you have { dispatchByDefault: true }
then you need to return an action otherwise it's misleading. With { dispatch: true }
TS won't let you emit anything but action. With { dispatchByDefault: true }
we can't do the same by TS so we need to keep the consistency and throw an error for the developer to know.
I get it now, thanks! Fell free to close this PR then๐
moved the filtering for only actions after checking if dispatching is true
removed the thrown error to fix the only actions filtering
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
closes #42