Closed samhh closed 1 year ago
It'd also be very useful to be able to decode structures like this:
{
tag: 'MemberName',
other: 'stuff',
here: 'too',
}
To:
Sum.Member<'MemberName', { other: string; here: string }>
This may need to operate over entire objects like t.type
.
Ideally it can also cover stuff like this:
{ tag: 'Human'; occupation: string } | { tag: 'Cat' }
And the tag needs to be flexible. Sometimes you might need to derive from a boolean property.
This is more complex than anything we already have. Maybe there's a layer of abstraction to discover first that's generalisable beyond sum-types.
Split out into #18, #19, #20, and #21.
Nullary sums now have
getCodecFromStringlyMappedNullaryTag
, but there's nothing equivalent for non-nullary sums if you don't want your data encoded specifically asSerialized
.Conversion functions like
getCodecFromMappedNullaryTag
, but with one or two supplied per member rather than across all members? How would this be handled in io-ts for non-primitive types?