Hi, I using Formik in my company's main project. and i faced this problem
Type '{ FIO: string; email: string; phone: string; dob: string; country: string; city: string; }'
is not assignable to type 'FormEvent<Element> &
{ FIO: string; email: string; phone: string; dob: string; country: string; city: string; }'.
Type '{ FIO: string; email: string; phone: string; dob: string; country: string; city: string; }'
is missing the following properties from
type 'FormEvent<Element>': nativeEvent, currentTarget, target, bubbles, and 11 more.

https://codesandbox.io/s/formik-boilerplateexample-64ugl?file=/src/App.tsx
I expect no TS errors
How could I solve this bug? Why this happended?
VSCode said that initialValues should be that kind of type
(property) initialValues: React.FormEvent<Element> & {
FIO: string;
email: string;
phone: string;
dob: string;
country: string;
city: string;
}
The expected type comes from property 'initialValues' which is declared here - types.d.ts(143, 5)
| Software | windows 64-x
| ---------------- | ---------- |
| Formik | 2.1.4
| React | 16.13.1
| TypeScript | 3.8.2
| Browser | Chrome
| npm/Yarn | yarn
| Operating System | windows
I really can't move on cause i stuck with this problem(((
@Manimall What is the type signature of your onSubmit function? Formik will infer the generic type for Values in the form from the onSubmit prop if a generic is not passed directly:
Shortened version of the interface for <Formik> prop:
interface FormikConfig<Values> {
/**
* Submission handler
*/
onSubmit: (
values: Values,
formikHelpers: FormikHelpers<Values>
) => void | Promise<any>;
}
If your onSubmit function's type signature is updated to not include FormEvent<Element>, then the type issue should be resolved.
@HipsterBrown thank you so much!
Most helpful comment
@Manimall What is the type signature of your
onSubmitfunction? Formik will infer the generic type forValuesin the form from theonSubmitprop if a generic is not passed directly:Shortened version of the interface for
<Formik>prop:If your
onSubmitfunction's type signature is updated to not includeFormEvent<Element>, then the type issue should be resolved.