Skip to content

Typescript error on validation #97

Closed
@cinemaster

Description

@cinemaster

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions