Formik: Issue with Typescript Definitions using withFormik()

Created on 18 Aug 2018  路  8Comments  路  Source: formium/formik

Current Behavior

Recently upgraded from v0.11.11 to 1.0.3. When attempting to build, my forms that
were once building now have the following typescript error:

Property 'registerField' is missing in type 'SingleStepProps & FormikState<FormValues> & FormikActions<FormValues> & FormikHandlers & FormikComputedProps<FormValues> & { children?: ReactNode; }'.

Steps to Reproduce

Build SFC component
export const MyForm: SFC<OtherFormProps & FormikProps<FormValues>>

then attempt to wrap it in withFormik().

Expected behavior

Typescript should still compile

Suggested solution(s)

Not sure what's wrong with the definitions that's causing it.

Additional context


The error is actually quite long and I have no idea how to decipher this, but it worked on previous versions of Formik.

image


  • Formik Version: 1.0.3
  • React Version: 16.4.2
  • TypeScript Version: 3.0.1
  • Browser and Version: Firefox 61.0.2
  • OS: Mac
  • Node Version: 8.9.1
  • Package Manager and Version: 6.1.0

Most helpful comment

Looking at this now. I think I know what happened.

All 8 comments

Hrmmm. Let me look into this.

I've got the same Error when trying to compile the provided Example:

https://github.com/jaredpalmer/formik#withformik

TS2345: Argument of type '(props: OtherProps & FormikSharedConfig & FormikState<FormValues> & FormikActions<FormValues> & FormikHandlers & FormikComputedProps<FormValues> & { registerField(name: string, fns: { ...; }): void; unregisterField(name: string): void; }) => Element' is not assignable to parameter of type 'CompositeComponent<InjectedFormikProps<MyFormProps, FormValues>>'.
  Type '(props: OtherProps & FormikSharedConfig & FormikState<FormValues> & FormikActions<FormValues> & FormikHandlers & FormikComputedProps<FormValues> & { registerField(name: string, fns: { ...; }): void; unregisterField(name: string): void; }) => Element' is not assignable to type 'StatelessComponent<InjectedFormikProps<MyFormProps, FormValues>>'.
    Types of parameters 'props' and 'props' are incompatible.
      Type 'MyFormProps & FormikState<FormValues> & FormikActions<FormValues> & FormikHandlers & FormikComputedProps<FormValues> & { children?: ReactNode; }' is not assignable to type 'OtherProps & FormikSharedConfig & FormikState<FormValues> & FormikActions<FormValues> & FormikHandlers & FormikComputedProps<FormValues> & { registerField(name: string, fns: { ...; }): void; unregisterField(name: string): void; }'.
        Type 'MyFormProps & FormikState<FormValues> & FormikActions<FormValues> & FormikHandlers & FormikComputedProps<FormValues> & { children?: ReactNode; }' is not assignable to type '{ registerField(name: string, fns: { validate?: ((value: any) => string | Function | Promise<void> | undefined) | undefined; }): void; unregisterField(name: string): void; }'.
          Property 'registerField' is missing in type 'MyFormProps & FormikState<FormValues> & FormikActions<FormValues> & FormikHandlers & FormikComputedProps<FormValues> & { children?: ReactNode; }'.

My Versions:

  • Formik Version: 1.1.1
  • React Version: 16.4.2
  • TypeScript Version: 3.0.1
  • OS: Ubuntu 18.04
  • Node Version: 10.9.0
  • Npm Version: 6.4.0

Any update on this? I'm also getting this issue.

Added more details in #862

Looking at this now. I think I know what happened.

Hi @jaredpalmer, did you end up finding the issue? Looking forward to getting rid of these build errors :)

This has been fixed

Looking at this now. I think I know what happened.

clarify please

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jaredpalmer picture jaredpalmer  路  3Comments

sibelius picture sibelius  路  3Comments

pmonty picture pmonty  路  3Comments

dfee picture dfee  路  3Comments

jaredpalmer picture jaredpalmer  路  3Comments