Skip to content

2.2.12

Compare
Choose a tag to compare
@gcanti gcanti released this 28 Oct 15:29
· 50 commits to master since this release
  • Experimental

(*) 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 })
})