question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

7.4.0-rc.0 flow imported type intersection error - Cannot read property 'length' of undefined in prop-types.js

See original GitHub issue

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.

 yarn list eslint-plugin-react eslint                                                                                                                                                                   ⏎
yarn list v0.27.5
├─ eslint-plugin-react@7.4.0-rc.0
└─ eslint@4.5.0
git clone https://github.com/alienfast/material-ui.git
git checkout remove-class-property-props
yarn install
yarn lint
Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
    at iterateProperties (/Users/kross/projects/material-ui/node_modules/eslint-plugin-react/lib/rules/prop-types.js:365:21)
    at propTypes.types.forEach.annotation (/Users/kross/projects/material-ui/node_modules/eslint-plugin-react/lib/rules/prop-types.js:798:13)
    at Array.forEach (<anonymous>)
    at markPropTypesAsDeclared (/Users/kross/projects/material-ui/node_modules/eslint-plugin-react/lib/rules/prop-types.js:796:27)
    at markAnnotatedFunctionArgumentsAsDeclared (/Users/kross/projects/material-ui/node_modules/eslint-plugin-react/lib/rules/prop-types.js:911:7)
    at Object.handleStatelessComponent (/Users/kross/projects/material-ui/node_modules/eslint-plugin-react/lib/rules/prop-types.js:920:7)
    at Linter.updatedRuleInstructions.(anonymous function) (/Users/kross/projects/material-ui/node_modules/eslint-plugin-react/lib/util/Components.js:666:75)
    at emitOne (events.js:120:20)
    at Linter.emit (events.js:210:7)
    at NodeEventGenerator.applySelector (/Users/kross/projects/material-ui/node_modules/eslint/lib/util/node-event-generator.js:265:26)

It appears to be failing when visiting IntersectionTypeAnnotation:

prop-types_js_-material-ui-___projects_material-ui

How can I help narrow this down further?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:13 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
jseminckcommented, Sep 6, 2017

@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 npm i --save-dev if you use npm)

rm -rf node_modules/eslint-plugin-react/
yarn add -D https://github.com/jseminck/eslint-plugin-react#intersection-imported-type
1reaction
bsr203commented, Sep 6, 2017

hi @yannickcr

I get a different stack this time.

Cannot read property 'name' of undefined
TypeError: Cannot read property 'name' of undefined
    at propTypes.types.forEach.annotation (/Users/bsr/client/node_modules/eslint-plugin-react/lib/rules/prop-types.js:726:49)
    at Array.forEach (<anonymous>)
    at declarePropTypesForIntersectionTypeAnnotation (/Users/bsr/client/node_modules/eslint-plugin-react/lib/rules/prop-types.js:725:23)
    at markPropTypesAsDeclared (/Users/bsr/client/node_modules/eslint-plugin-react/lib/rules/prop-types.js:831:35)
    at markAnnotatedFunctionArgumentsAsDeclared (/Users/bsr/client/node_modules/eslint-plugin-react/lib/rules/prop-types.js:937:7)
    at Object.handleStatelessComponent (/Users/bsr/client/node_modules/eslint-plugin-react/lib/rules/prop-types.js:946:7)
    at Linter.updatedRuleInstructions.(anonymous function) (/Users/bsr/client/node_modules/eslint-plugin-react/lib/util/Components.js:666:75)
    at emitOne (events.js:120:20)
    at Linter.emit (events.js:210:7)
    at NodeEventGenerator.applySelector (/Users/bsr/client/node_modules/eslint/lib/util/node-event-generator.js:265:26)
Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Cannot read property 'PropTypes' of undefined ...
First of all, give up on importing PropTypes from react . It is deprecated. Instead, start using import PropTypes from 'prop-types The rest ......
Read more >
typeerror: cannot read property 'location' of undefined jest
I found that I can mock the React Router hooks like useLocation using the following pattern: import React from "react ...
Read more >
Typeerror: Cannot Read Property 'length' of Undefined
The length property returns a number for essentially any object in JavaScript. Typeerrors can be thrown when attempting to change a value that ......
Read more >
3101543-18-REROLL.patch - Drupal
isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; ... Drupal); \ No newline at end of file...
Read more >
Compare Versions | pangling | npm - Open Source Insights
GHSA-vfrc-7r7c-w9mxPrototype Pollution in highlight.js ... @babel/plugin-transform-flow-strip-types 7.19.0 ... @types/prop-types 15.7.5.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found