Skip to content

I have objects with more than 14 fields :( #7

@radix

Description

@radix

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 b

however, I have no idea if TypeScript supports the type trickery required for a API like this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions