TS2322: Type
FieldApi<{ firstName: string; }, "firstName", string, FieldValidateOrFn<{ firstName: string; }, "firstName", string> | undefined, ({ value }: { value: string; fieldApi: FieldApi<{ ...; }, ... 21 more ..., any>; }) => "A first name is required" | ... 1 more ... | undefined, ... 17 more ..., never>
is not assignable to type AnyFieldApi
The types of form.options.listeners are incompatible between these types.
Type 'FormListeners<{ firstName: string; }, FormValidateOrFn<{ firstName: string; }> | undefined, FormValidateOrFn<{ firstName: string; }> | undefined, FormAsyncValidateOrFn<...> | undefined, ... 7 more ..., never> | undefined' is not assignable to type 'FormListeners<any, any, any, any, any, any, any, any, any, any, any, any> | undefined'.
Type 'FormListeners<{ firstName: string; }, FormValidateOrFn<{ firstName: string; }> | undefined, FormValidateOrFn<{ firstName: string; }> | undefined, FormAsyncValidateOrFn<...> | undefined, ... 7 more ..., never>' is not assignable to type 'FormListeners<any, any, any, any, any, any, any, any, any, any, any, any>'.
Types of property onChange are incompatible.
Type '((props: { formApi: FormApi<{ firstName: string; }, FormValidateOrFn<{ firstName: string; }> | undefined, FormValidateOrFn<{ firstName: string; }> | undefined, ... 8 more ..., never>; fieldApi: AnyFieldApi; }) => void) | undefined' is not assignable to type '((props: { formApi: FormApi<any, any, any, any, any, any, any, any, any, any, any, any>; fieldApi: AnyFieldApi; }) => void) | undefined'.
Type '(props: { formApi: FormApi<{ firstName: string; }, FormValidateOrFn<{ firstName: string; }> | undefined, FormValidateOrFn<{ firstName: string; }> | undefined, ... 8 more ..., never>; fieldApi: AnyFieldApi; }) => void' is not assignable to type '(props: { formApi: FormApi<any, any, any, any, any, any, any, any, any, any, any, any>; fieldApi: AnyFieldApi; }) => void'.
Types of parameters props and props are incompatible.
Type '{ formApi: FormApi<any, any, any, any, any, any, any, any, any, any, any, any>; fieldApi: AnyFieldApi; }' is not assignable to type '{ formApi: FormApi<{ firstName: string; }, FormValidateOrFn<{ firstName: string; }> | undefined, FormValidateOrFn<{ firstName: string; }> | undefined, ... 8 more ..., never>; fieldApi: AnyFieldApi; }'.
The types of formApi.options.listeners are incompatible between these types.
Type 'FormListeners<any, any, any, any, any, any, any, any, any, any, any, any> | undefined' is not assignable to type 'FormListeners<{ firstName: string; }, FormValidateOrFn<{ firstName: string; }> | undefined, FormValidateOrFn<{ firstName: string; }> | undefined, FormAsyncValidateOrFn<...> | undefined, ... 7 more ..., never> | undefined'.
Type 'FormListeners<any, any, any, any, any, any, any, any, any, any, any, any>' is not assignable to type 'FormListeners<{ firstName: string; }, FormValidateOrFn<{ firstName: string; }> | undefined, FormValidateOrFn<{ firstName: string; }> | undefined, FormAsyncValidateOrFn<...> | undefined, ... 7 more ..., never>'.
Type any is not assignable to type never
react-form and svelte adapter. I didn't check other frameworks.
Describe the bug
When I try to pass
fieldobject (FieldApi) to prop of typeAnyFieldApiI get a type error. It only happens when the form object fromuseFormwas created using theformOptionsfunction.Your minimal, reproducible example
https://stackblitz.com/edit/vitejs-vite-qffrfz9w?file=src%2FApp.tsx
Steps to reproduce
fieldobject tofieldprop ofFieldInfocomponent.onSubmithandler fromformOptions.Also, if you take the stuff you pass into
formOptionsand directly pass it touseForm, (skippingformOptionscompletely) there is no type error. But I need to reuse the options in otheruseFormcalls.The repro code is the example from https://tanstack.com/form/latest, when you scroll all the way down. I just moved the options to
formOptionsinstead of passing them directly touseForm.Expected behavior
The type error should not happen when
onSubmithandler is present informOptions.How often does this bug happen?
Every time
Screenshots or Videos
Platform
rocky linux, chrome 139
TanStack Form adapter
react-form and svelte adapter. I didn't check other frameworks.
TanStack Form version
^1.23.5
TypeScript version
~5.9.3
Additional context