form icon indicating copy to clipboard operation
form copied to clipboard

`field.state.meta.errors` typed as `unknown[]`

Open humemm opened this issue 1 year ago • 2 comments

field.state.meta.errors typed as unknown[]

Description

In the past week or so, updating to the latest version of @tanstack/react-form introduced a regression: field.state.meta.errors is now typed as unknown[], breaking previously valid code like:

const form = useForm({
  defaultValues: {
    login: '',
    password: '',
  },
  validators: {
    onSubmitAsync: async ({ value }) => {
      return {
        fields: {
          login: { message: 'some error message' }
        }
      }
    }
  }
})

<span>{field.state.meta?.errors[0]?.message}</span>

humemm avatar Jun 19 '25 21:06 humemm

How is field defined in your code snippet? Could you create a reproducible example on something like stackblitz or codesandbox?

LeCarbonator avatar Jun 20 '25 05:06 LeCarbonator

It turns out some genius deleted parts of our tsconfig, specifically the strict compiler option. Sorry for the spam.

humemm avatar Jun 21 '25 02:06 humemm