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

Different form state and component FieldValue types

Open
#807 0 comments 0 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**?
Can be bug.

### What is the current behavior?
In current TS implementation you cannot make `FieldProps` to have different types for state and renderable component.
![image](https://user-images.githubusercontent.com/16340846/83885279-cc97a780-a74e-11ea-9608-0234fd65ef68.png)

It throws error:
```
Type 'string' is not assignable to type '{ type: "string"; data: string; }'.
```

In `UseFieldConfig` type `FieldValue` represents value passed to state and it cannot be changed.

![image](https://user-images.githubusercontent.com/16340846/83885644-4def3a00-a74f-11ea-9412-85b56a00dbb7.png)

**Not sure how to fix it:**
- "flip" `FieldValue` and `any` in `UseFieldConfig`
- fix `FieldProps` somehow

**Temp workaround**
```ts
type TempWorkaround = FieldProps>;
```

### What is the expected behavior?
You can set input component value and state value types.

### Sandbox Link

https://codesandbox.io/s/vibrant-leakey-el0fn?file=/src/index.tsx

### What's your environment?

### Other information

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.