elm-ts-json
elm-ts-json copied to clipboard
Add support for int unions
Currently I use
TsJson.Codec.stringUnion
[ ( "0", Reliable )
, ( "1", Lossy )
, ( "-1", Unrecognized )
]
to encode data for a JS library. The resulting type is "0" | "1" | "-1"
and I have to call parseInt
on the JS side to prepare data for the library. It would be nice to simply write
TsJson.Codec.intUnion
[ ( 0, Reliable )
, ( 1, Lossy )
, ( -1, Unrecognized )
]
to get 0 | 1 | -1
type and avoid extra conversion on the JS side.