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

Flow types: intersecting inexact shape types is too buggy, causes errors in userland with more recent versions of flow

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

Description

Let me know if you want a PR...I think we need to investigate workarounds before we proceed...

I'm getting errors like this:
```js
Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ src/universal/components/CalibrationForm/index.js:119:10

Cannot create FieldArray element because property defaultValue is missing in object type [1] but exists in props [2].

src/universal/components/CalibrationForm/index.js
116│
117│ if (isInCalibration) {
118│ return (
[2] 119│ (
124│
130│ )}
131│ />

node_modules/react-final-form-arrays/dist/types.js.flow
[1] 43│ export type RenderableProps = $Shape<{
44│ children: (props: T) => React.Node,
45│ component: React.ComponentType<*>,
46│ render: (props: T) => React.Node
47│ }>
```

Problem is here: https://github.com/final-form/react-final-form-arrays/blob/16f19c538acb62f0410ad6aaf69ccd386fded0a0/src/types.js.flow#L57

Intersecting inexact shape types in Flow has always caused problems like this sporadically.

It seems like this appears to work, though I don't trust it until I've played with it more:

```js
type FieldArrayProps = { name: string, ...$Exact, ...$Exact> }
```

I don't trust it until I've played with it more though, because I remember seeing inexact spreads like `{ name: string, ...UseFieldArrayConfig }` produce buggy errors (https://github.com/facebook/flow/issues/1326#issuecomment-523286703).

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.