Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validateFields is missing in the type definition of FieldProps #85

Closed
micurs opened this issue Dec 28, 2017 · 3 comments
Closed

validateFields is missing in the type definition of FieldProps #85

micurs opened this issue Dec 28, 2017 · 3 comments

Comments

@micurs
Copy link

micurs commented Dec 28, 2017

bug report

Missing validateFields in type definition for FieldProps

When I try to compile a Field using validateFields={[]} the TypeScript compiler gives me an error:

error TS2339: Property 'validateFields' does not exist on type 'IntrinsicAttributes & { allowNull?: boolean | undefined; format?: ((value: any, name: string) => ...'.

My sample code is:

  <Field name="last_name" validate={this.validateRequired} validateFields={[]}>
    {( { meta, input } ) => (
      <input
         type="text"
         className={(!meta.pristine || meta.touched ? meta.error || 'Valid' : '' ) as string}
         {...input}
      />)}
  </Field>

I changed the FieldProps definition in index.d.ts and the error went away:

export type FieldProps = {
  allowNull?: boolean
  format?: ((value: any, name: string) => any) | null
  parse?: ((value: any, name: string) => any) | null
  name: string
  subscription?: FieldSubscription
  validate?: (value: any, allValues: object) => any
  value?: any
  validateFields?: string[]
} & RenderableProps<FieldRenderProps>

Can you confirm? I can submit a PR with the change if ok with you.

Thank you
Michele

@yurist38
Copy link

yurist38 commented Dec 5, 2018

Confirm this. Just was about to report the same...

Types definition

@yurist38
Copy link

yurist38 commented Dec 5, 2018

I just had a look at it and it's actually kinda weird.

https://github.com/final-form/react-final-form/blob/master/src/types.js.flow#L89

It takes a definition of validate method from final-form package. The strange thing here is that final-form has meta inside:

https://github.com/final-form/final-form/blob/master/src/types.js.flow#L111

Any idea why it can happen?

@gertdreyer
Copy link
Collaborator

Solved in recent versions

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants