Skip to content

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

Open
@jedwards1211

Description

@jedwards1211

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)).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions