Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve inference on parametrized record fields #2

Open
schicks opened this issue Aug 20, 2020 · 0 comments
Open

Improve inference on parametrized record fields #2

schicks opened this issue Aug 20, 2020 · 0 comments

Comments

@schicks
Copy link
Owner

schicks commented Aug 20, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant