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

FieldInputProps interface incorrectly extends AnyObject

Open
#991 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.4k
Forks
497
PR merge metrics
No merged PRs in 30d

Description

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

### What is the current behavior?
`FieldInputProps` extends `AnyObject`, creating the assumption that `input` can include any field beyond the defined values.

### What is the expected behavior?
`FieldInputProps` doesn't extend `AnyObject` since it's explicit in its declaration what it includes.

### Sandbox Link

### What's your environment?

React Final Form v6.5.9
Final Form v4.20.7
TypeScript v4.6.2

### Other information

The `FieldInputProps` interface [extends an `AnyObject` interface](https://github.com/final-form/react-final-form/blob/334f0015989e15a10f6741b87955c535593f2bde/typescript/index.d.ts#L31) that is just an index signature. As a result, the code assumes that the `input` object that exists in the field render props can include any number of fields beyond what is explicitly defined. However, the `useField` hook that is exported directly and used in the `Field` component internally [explicitly defines the `input` object](https://github.com/final-form/react-final-form/blob/334f0015989e15a10f6741b87955c535593f2bde/src/useField.js#L140-L229) with the keys matching the `FieldInputProps` interface. Given that, there is no reason to have `FieldInputProps` extend this index signature.

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.