Open OliverJAsh opened 2 years ago
@OliverJAsh looks like io-ts
detects Union
as a tagged union (being "premium" the tag) and executes this path https://github.com/gcanti/io-ts/blob/63eea029773595b6a9cff9d70894935ae7a20e7e/src/index.ts#L1598 since {}['premium']
is undefined
, so it returns early without giving withFallback
a chance.
Not sure what's the possible fix, maybe execute a deoptimized validate instead of bailing out: https://github.com/gcanti/io-ts/compare/gcanti:63eea02...gcanti:11ecad3
WDYT?
That looks good to me but I'm not too familiar with the implementation. Maybe @mlegenhausen has some thoughts?
@gcanti this would be great. I think this should also cover possible other errors that could be introduced by custom types.
🐛 Bug report
Current Behavior
Expected behavior
See code comments above.
If
Free.decode(z)
returns aRight
then I believeUnion.decode(z)
should also return aRight
?Reproducible example
Suggested solution(s)
Additional context
Your environment
package.json
: