Improving Error Messages for Union Types in TypeScript

Hi guys. For an union like this:

Schema.Union(
  Schema.Literal("JSON"),
  Schema.Literal("FormData"),
  Schema.Literal("XML"),
)


How do I improve the error message? I ask that because when I decode an invalid value, I get something like:

ParseError: "JSON" | "FormData" | "XML"
├─ Expected "JSON", actual "json"
├─ Expected "FormData", actual "json"
└─ Expected "XML", actual "json"


ArrayFormatter also gives me 3 issues instead of one, which makes it quite hard to work with
Was this page helpful?