Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jedwards1211 opened this issue Sep 17, 2020 · 3 comments

Comments

@jedwards1211
Copy link

jedwards1211 commented Sep 17, 2020

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

@jedwards1211 jedwards1211 changed the title Flow types: intersecting inexact shape types just doesn't work Flow types: intersecting inexact shape types just doesn't work and causes errors in userland Sep 17, 2020
@jedwards1211 jedwards1211 changed the title Flow types: intersecting inexact shape types just doesn't work and causes errors in userland Flow types: intersecting inexact shape types just doesn't work, and causes errors in userland Sep 17, 2020
@jedwards1211 jedwards1211 changed the title Flow types: intersecting inexact shape types just doesn't work, and causes errors in userland Flow types: intersecting inexact shape types is too buggy, causes errors in userland Sep 17, 2020
@jedwards1211
Copy link
Author

jedwards1211 commented Sep 17, 2020

It's reproducible in try flow:

https://flow.org/try/#0PTAEAEDMBsHsHcBQBLAtgB1gJwC6gFSgCGAzqAEoCmRAxnpFrKqAORbV0uI4Ce6loAGLJK0ACYBlAK4AjEjSzJ0OZLAB2oALygA3gG0SORWoDmAXQBcoGbFjRqagL6IQoQ7JmUxb5GpoCASVAaIjUWPDRMXFAGJhjfImgAWkhsZgALSnZuPgFhUUkcIhwBbR0AHwA3ROQxKxs7B3LnHP5QAFlKIq1QABIJdKJ+AB4dRFBiOmRKygB+ett7UIAacdAxYqJ50AB5GQArSjpVibFkXB5thqW1E-Xz3glffwAZUhxpGVRkHCvFhzuWUYWG2oR4d18P2QiVBanBa181WgtT+jRWa3sphw6W2aikqE8WDuqFgZ0gIjEqJud3QikMvjmCzRtzWJFk3xwAFEsMDYfCJmyvj9BERkPZKUzqaz2T9pDR-F4vFSAdKhTgVKZleiJjhYFIaJkJdZ-trQEiUZKVRNKsgSD8lZbQohHAA+RCISgADyieF4bXy4gAgjyiDwqGoxFkAAqMdBkMprckFEhWMYTCapLCc2jpKwACntWGK2HzaiIqEoVkMxhMy1AvkjnqseIJWQAlFoXWbYLUO5ou5Ue2I7hNfCQsjh8w2vc38YS60ipJXiHC+wOhyPQKghlOSkXdVhS+Xl9XfLX6xGZ6AW4S1yueHewXozJuSTN87FULPW0TQLrv7enbdrUm5lhWVZGGem6YOg+aPnC0FSCQuagHmi7LmCd6DiBawTOwb7LgWl5Ntec7tkBYKbshyCQJOqHwfy6YkPAO6odOnqBgBWR1uxABCXFYFhG64aAUhqNRtH5uhViYUB2HDiJ0n3s+ayOMSXREFYnRFM67pej6f65BQlCXkWMj2DGsBxsMAAqXbaP0gwjGmwTpGKYjsGo+a0lZKagDZd5ULQOAAHQAHKkpQdw0EwmBqCZdFBXQIUAMKxeoCU2bkwz4C6dyeZGh6oT5cZWAFQFJaFEWRs6boet62C+kZACq44BmIwZFjwaVqOSJg9C5gryIoyiqGo2ztZ8w1KCo6h3JGkBEFI0A4AAaokS58hCahQok63QJtMkIQiJCcgAjlIML5k+L7KWYd7XFaZo1BsJTbGhG3LrMeY3W2daJNA+1Ln5eyHMcW4aVYsyTUUJR3rMYK6fVBl+nkIhBiGPCWXGA3XseEE1qAjigAAZKArWUO1nWhj1fWk2s4aFUQ5mUNjJDDFTmOM9GsYkHV+mNYZ-rox1mNswATANaxgSekGmNFbniJ570lX5nNddzWBs4FHBVZF0XpfFai-FYlWpYbmXZbl+UmYVKu81Y6uhpr2sVbr4X66q02jeoE0i1NCgzWN82UIty1rZ9W0IjtKh7ZHR2Mba52XdA703f9cLPg9JostaL3FIyqFKd9v3-dAgOfSDBxHDgdYVkUUMwwX8OIy0MXifQtiOyL1NY7zUt4+BrCpLALB1hMSPt4YMS2OL3cFL3EsDzLVgsCPY-ps6QA

@jedwards1211
Copy link
Author

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

@jedwards1211 jedwards1211 changed the title Flow types: intersecting inexact shape types is too buggy, causes errors in userland Flow types: intersecting inexact shape types is too buggy, causes errors in userland with more recent versions of flow Sep 17, 2020
@Nikola-Andreev
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants