-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
7.4.0-rc.0 flow imported type intersection error - Cannot read property 'length' of undefined in prop-types.js #1413
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
Comments
Thanks for looking into this. I guess it is related to: #1404 where we added support for the IntersectionTypeAnnotation. I can fix the crash easily, but can we even properly validate the props in this case? Since they are imported from another file, we do not what's inside them... 😞 |
I did a quick check and there were 2 issues:
|
@rosskevin @bsr203 can you check out https://github.com/jseminck/eslint-plugin-react/tree/intersection-imported-type and see if it fixes the issue for you? I've added test cases that cover the examples here. @rosskevin did the issue appear in the material-ui code base? Yesterday I was looking around for open-source code bases that we could use to test releases. Perhaps it's a good candidate? My other ideas so far were https://codesandbox.io/ & https://babeljs.io/repl/ 😄 |
I tested on material-ui with this branch and found another problem with the I think it's the following case: export type Props = HiddenProps & {
/**
* Useful to extend the style applied to components.
*/
classes?: Object,
}; |
hi @yannickcr I get a different stack this time.
|
@bsr203 see my last comment. I just pushed a fix to my branch and tested it on the material-ui project and now everything passes 🎉 I still have to clean up the code though... it's a bit messy. To try it out (or
|
@jseminck everything looks good for me. no crash and also props are being detected. thanks again for the quick fix and help. |
Thanks everyone for the assistance. Regarding importing from other files, it is possible. I did some research into the matter and commented my findings here: brigand/babel-plugin-flow-react-proptypes#106 (comment) Essentially, this is a common problem and |
Cool. Thanks for testing @bsr203. I'll clean up the code and push the changes. It'll take a bit of time as I have some things to attend to. Regarding imports from other files: For now I'll stick to the same logic as we applied previously: if there's an import of a type, then we cannot find it, and we just skip props validation for that file. I'll try to read through that thread later and see how complicated it is 😄 |
@jseminck - if there is a way to extract that code and grab imported types, it might be a generally useful utility project. I know the And yes, the callemall/material-ui#v1-beta is a perfect project for smoke testing! |
Closely related to this issue I'm also seeing the following code: type SomeType = {};
type SomeOtherType = {
a: number
} & SomeType; Result in the following
|
We are heavy flow users and are on flow 0.54.0, so I assume this may be related to @jseminck's changes in #1400. This may be an entirely new case or separate bug.
It appears to be failing when visiting
IntersectionTypeAnnotation
:How can I help narrow this down further?
The text was updated successfully, but these errors were encountered: