TanStackT
TanStack9mo ago
43 replies
comprehensive-tomato

Lack of Type Safety with Pre-bound Field Components?

https://tanstack.com/form/latest/docs/framework/react/guides/form-composition#pre-bound-field-components
This documentation suggests that pre-bound field components "infer" that such a field should assume that the value in the form state has the same type as the type argument to useFieldContext. However, this means that whenever I'm actually using the pre-bound field, there are no guardrails preventing me from using a pre-bound field with a form value of a different type.

Demonstrating in code, it seems like a big danger that I can do this:
  <form.AppField name="number">
    {(field) => (
      <field.String />
    )}
  </form.AppField>


Is this something I can actually assert? Or if not are there plans to get around it?
A common criticism of TanStack Form is its verbosity out-of-the-box. While this can be useful for educational purposes helping enforce understanding our APIs it's not ideal in production use cases. As...
Form Composition | TanStack Form React Docs
Was this page helpful?