Skip to main content
Version: Current (v7.0.0-beta.3)

A typed handler no longer fits a bare FormProps

Detect​

  • In your code: a props object or a wrapper component typed as bare FormProps that takes typed handlers, such as customValidate: (formData: MyData | undefined, …) or onSubmit: (e: IChangeEvent<MyData>) => ….
  • The type checker reports Type '…' is not assignable to type '…'. (TS2322) on that handler.

Change​

Values annotated without a type argument still fit a typed form, but the reverse does not hold: FormProps means FormProps<unknown>, and a handler typed for MyData doesn't fit it. Give FormProps your data type:

-function MyForm(props: FormProps) {
+function MyForm(props: FormProps<MyData>) {
return <Form {...props} />;
}

Verify​

  • The type checker accepts the typed handlers on the props object or wrapper.
  • Nothing changes at runtime.

Also read: