-
Notifications
You must be signed in to change notification settings - Fork 9
Description
Hi!
I am in the unfortunate situation of having objects with more than 14 fields, and the object function only supports up to that many (at least, in a type-safe way). Does it make sense to just add more type declarations (I hope TS itself doesn't have a limit on the number of type variables...) or should there be some other more incremental API for decoding objects with large number of fields?
Elm's Json.Decoder only supports up to 5 fields at a time, but there is another package called elm-decode-pipeline which supports a more flexible framework for decoding these large objects. You use a syntax like this:
decode User
|> required "id" int
|> required "email" string
|> optional "name" string ""where decode and required have these type signatures:
decode : a -> Decoder a
required : String -> Decoder a -> Decoder (a -> b) -> Decoder bhowever, I have no idea if TypeScript supports the type trickery required for a API like this.