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

Typescript error on validation #97

Closed
cinemaster opened this issue Jul 12, 2019 · 5 comments · Fixed by #108
Closed

Typescript error on validation #97

cinemaster opened this issue Jul 12, 2019 · 5 comments · Fixed by #108

Comments

@cinemaster
Copy link
Contributor

Are you submitting a bug report or a feature request?

bug report

What is the current behavior?

It's just error on typescripts.

Type '(value: UserValue[]) => ValidationErrors[]' is not assignable to type 'FieldValidator<UserValue>'.
  Types of parameters 'value' and 'value' are incompatible.
    Type 'UserValue' is missing the following properties from type 'UserValue[]': length, pop, push, concat, and 28 more.  TS2322

    221 |                     ...
    222 |                   />
  > 223 |                   <FieldArray<UserValue> name="users" validate={this.validateUser}>
        |                                                        ^
    224 |                     {({ fields }) => (
    225 |                       ...

and my validation is

validateUser = (value: UserValue[]) => {
	...
};

What is the expected behavior?

I think on definition UseFieldArrayConfig interface here, it should be assigned validate method as validate?: FieldValidator<FieldValue[]>.Otherwise it's defined with FieldValidator<FieldValue> and it occurs above type mismatch.

What's your environment?

% grep final-form ./package.json
./package.json:10:    "final-form": "^4.16.1",
./package.json:11:    "final-form-arrays": "^1.1.2",
./package.json:21:    "react-final-form": "^6.3.0",
./package.json:22:    "react-final-form-arrays": "^3.1.0",

Other information

If this change is ok, I can create PR for this.

@erikras
Copy link
Member

erikras commented Jul 12, 2019

Or maybe...

extends UseFieldConfig<FieldValue> ➡️ extends UseFieldConfig<FieldValue[]>

?

@cinemaster
Copy link
Contributor Author

Ah, yes.
It's much better, I think.

@MaciejSzewczyszyn
Copy link

Hi, any progress on this?

@evgenii-bond
Copy link

any progress on this?

@erikras
Copy link
Member

erikras commented Jul 23, 2020

Published fix in v3.1.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants