final-form / final-form/react-final-form-arrays

Unused type argument in FieldArrayRenderProps

Open
#173 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
210
Forks
69
PR merge metrics
No merged PRs in 30d

Description

### Are you submitting a **bug report** or a **feature request**?

TS typing dead code

### What is the current behavior?

`interface FieldArrayRenderProps` requires 2 generic arguments however the second one is unused.

### What is the expected behavior?

`interface FieldArrayRenderProps` requires only one generic argument which represents value type.

### Sandbox Link

[https://codesandbox.io/s/react-final-form-field-arrays-forked-7wuwcb?file=/index.tsx]()

### What's your environment?

```
"final-form": "4.20.7",
"final-form-arrays": "3.0.2",
"react": "16.8.6",
"react-dom": "16.8.6",
"react-final-form": "6.5.9",
"react-final-form-arrays": "3.1.4"
```

### Other information

When you take a look at the interface, the second type argument is never used. Therefore it's useless. I think that it should be removed however it would be breaking change since the generic interface might be already used with 2 arguments in other projects. Removing the second type argument would cause error `TS2314: Generic type 'FieldArrayRenderProps ' requires 1 type argument(s).`.

```ts
export interface FieldArrayRenderProps {
fields: {
forEach: (iterator: (name: string, index: number) => void) => void
insert: (index: number, value: FieldValue) => void
map: (iterator: (name: string, index: number) => R) => R[]
move: (from: number, to: number) => void
update: (index: number, value: FieldValue) => void
name: string
pop: () => FieldValue
push: (value: FieldValue) => void
remove: (index: number) => FieldValue
shift: () => FieldValue
swap: (indexA: number, indexB: number) => void
unshift: (value: FieldValue) => void
value: FieldValue[]
} & FieldState
meta: Partial<{
// TODO: Make a diff of `FieldState` without all the functions
active: boolean
dirty: boolean
dirtySinceLastSubmit: boolean
error: any
initial: any
invalid: boolean
pristine: boolean
submitError: any
submitFailed: boolean
submitSucceeded: boolean
touched: boolean
valid: boolean
visited: boolean
}>
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.