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

Unused type argument in FieldArrayRenderProps #173

Open
dominikdosoudil opened this issue Nov 2, 2022 · 0 comments
Open

Unused type argument in FieldArrayRenderProps #173

dominikdosoudil opened this issue Nov 2, 2022 · 0 comments

Comments

@dominikdosoudil
Copy link

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)..

export interface FieldArrayRenderProps<FieldValue, T extends HTMLElement> {
  fields: {
    forEach: (iterator: (name: string, index: number) => void) => void
    insert: (index: number, value: FieldValue) => void
    map: <R>(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<FieldValue[]>
  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
  }>
}
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

No branches or pull requests

1 participant