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

Type problems/improvements in 6.3.3

Open
#684 0 comments 2 reactions 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**?

bug report (or improvement over the new types introduced with renderable props types).

### What is the current behavior?

Passing the value as the first generic argument of `Field` is not enough to get the input value's correct type.
![image](https://user-images.githubusercontent.com/15076656/69552446-26046a00-0fa7-11ea-91a3-2f39008ae06f.png)

You must pass at least the second argument partially to get it right:
![image](https://user-images.githubusercontent.com/15076656/69552686-8e534b80-0fa7-11ea-8e7b-711c5529d34f.png)

### What is the expected behavior?
Passing the first argument could be enough.

### What's your environment?

`"react-final-form": "6.3.3"`
`"final-form": "4.18.5"`

### Other information

A possible fix in `index.d.ts`:
```ts
export interface FieldProps<
FieldValue,
T extends HTMLElement = HTMLElement,
RP extends FieldRenderProps = FieldRenderProps
> extends UseFieldConfig, RenderableProps {
name: string;
[otherProp: string]: any;
}

export const Field: <
FieldValue,
T extends HTMLElement = HTMLElement,
RP extends FieldRenderProps = FieldRenderProps<
FieldValue,
T
>,
>(
props: FieldProps
) => React.ReactElement;
```

And there you go, as it used to be:
![image](https://user-images.githubusercontent.com/15076656/69552922-f30ea600-0fa7-11ea-9dd9-e73567243cb7.png)

An extra question. It doesn't seem to make sense to extend `AnyObject` here:
```ts
interface FieldInputProps extends AnyObject { //...
```

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.