I'm trying to reduce boilerplate of redux code typed with flow.
In particular, I want to avoid defining action types manually, but let flow deduce them from typed action creators, using the ExtractReturn tricks (as described for example in Shane Osbourne post or Martin Hochel post):
type _ExtractReturn<B, F: (...args: any[]) => B> = B;
type ExtractReturn<F> = _ExtractReturn<*, F>;
But it does not catch simple error, for example it should catch that action.id is a number and not a string: Try Flow.
If the action were defined "manually", error would be catched: Try Flow.
How can I have all errors properly catched in the reducer function, without writing manually boilerplate code?
- Edit: fixed the Try flow links.
- Edit: I didn't noticed that
Shane Osbourne postprovides aFlow Trythat seems to work. Looking at it. Actually, it has the same problem. Trying on write a comment on the post to signal it. See comment here