io-ts
2.2.22 · 10 Dec 2024MIT4.1M / weekRepositorynpmAtom feed
Your version
2.2.22 is the newest release of 2.x.
In short
1 breaking1 changed
- breaking
(*) breaking change
Release note
Experimental
(*) make
sumsafer, closes #523
(*) breaking change
In case of non-string tag values, the respective key must be enclosed in brackets
export const MySum: D.Decoder<
unknown,
| {
type: 1 // non-`string` tag value
a: string
}
| {
type: 2 // non-`string` tag value
b: number
}
> = D.sum('type')({
[1]: D.type({ type: D.literal(1), a: D.string }),
[2]: D.type({ type: D.literal(2), b: D.number })
})