react-final-form-arrays icon indicating copy to clipboard operation
react-final-form-arrays copied to clipboard

Incorrect typings for FieldArray.initialValues

Open ruscoder opened this issue 5 years ago • 1 comments

Are you submitting a bug report or a feature request?

Bug report

What is the current behavior?

I got an error when pass initialValues as an array

interface MyType {
    name: string;
}
...

<FieldArray<MyType> name="test" initialValue={[{name: ''}]}>
</FieldArray>

Error: Type: MyType[] has no properties in common with type MyType;

What is the expected behavior?

Compiling without errors

Sandbox Link

What's your environment?

"final-form": "^4.18.2",
"final-form-arrays": "^1.1.2",
"react-final-form": "^6.3.0",
"react-final-form-arrays": "^3.1.1",

Other information

I assume it can be solved by changing

export interface UseFieldArrayConfig<FieldValue>
  extends UseFieldConfig<FieldValue> {
  isEqual?: (a: any[], b: any[]) => boolean
}

to

export interface UseFieldArrayConfig<FieldValue>
  extends UseFieldConfig<FieldValue[]> {
  isEqual?: (a: any[], b: any[]) => boolean
}

ruscoder avatar Sep 06 '19 04:09 ruscoder

~@erikras hello! This problem still exists. If you don't mind I would fix it and open PR.~

My fault. It was fixed in v3.1.2, sorry for mention.

ddgrishkin avatar Oct 07 '22 17:10 ddgrishkin