Skip to content

Improve inference on parametrized record fields #2

@schicks

Description

@schicks

When a Field is constructed from a parametrized type, it can't correctly infer the underlying type without an explicit annotation. This is trivial to add, but irritating boilerplate.

const person = Record("person", {
    name: Field(String()),
    age: Field(Long()),
  });
const field = Field(person) // infers RequiredField<unknown>
const betterField = Field<typeof person>(person) //infers RequiredField<{name: string, age: number}>

Ideally fields would automatically do this inference, rather than needing to be "prompted" in this way. This feels like a higher kinded types problem though, so I'm not sure if there is a solution.

The issue exists for any field constructed with an underlying type which has a parameter.

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