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

jedwards1211 opened this issue · 3 comments

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

I'm getting errors like this:

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         <FieldArray
     120           name="points"
     121           key={numPoints + 1}
     122           validate={validatePoints}
     123           render={props => (
     124             <CalibrationTable
     125               {...props}
     126               units={units}
     127               rawInputUnits={rawInputUnits}
     128               bodyClass={classes.body}
     129             />
     130           )}
     131         />

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

Problem is here:

export type FieldArrayProps = { name: string } & UseFieldArrayConfig &

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:

type FieldArrayProps = { name: string, ...$Exact<UseFieldArrayConfig>, ...$Exact<RenderableProps<FieldArrayProps>> }

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 (facebook/flow#1326 (comment)).

It's reproducible in try flow:

https://flow.org/try/#0PTAEAEDMBsHsHcBQBLAtgB1gJwC6gFSgCGAzqAEoCmRAxnpFrKqAORbV0uI4Ce6loAGLJK0ACYBlAK4AjEjSzJ0OZLAB2oALygA3gG0SORWoDmAXQBcoGbFjRqagL6IQoQ7JmUxb5GpoCASVAaIjUWPDRMXFAGJhjfImgAWkhsZgALSnZuPgFhUUkcIhwBbR0AHwA3ROQxKxs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bl+UmYVKu81Y6uhpr2sVbr4X66q02jeoE0i1NCgzWN82UIty1rZ9W0IjtKh7ZHR2Mba52XdA703f9cLPg9JostaL3FIyqFKd9v3-dAgOfSDBxHDgdYVkUUMwwX8OIy0MXifQtiOyL1NY7zUt4+BrCpLALB1hMSPt4YMS2OL3cFL3EsDzLVgsCPY-ps6QA

Also the $Shape around Meta is unnecessary since all properties in it are optional anyway

The solution for me was to downgrade from 3.1.3 to 3.1.1
Please take care about it so in future we can use the newest versions.