final-form / react-final-form-arrays

A component for rendering and editing arrays 🏁 React Final Form
MIT License
205 stars 70 forks source link

Incorrect typings for FieldArray.initialValues #113

Open ruscoder opened 5 years ago

ruscoder commented 5 years ago

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
}
ddgrishkin commented 2 years ago

~@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.