You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
eslint-plugin-react v7.20.6 causes the following error:
ESLint: 7.6.0 (or 7.9.0)
TypeError: Cannot read property 'type' of undefined
Occurred while linting /path-to-file/Component.tsx:101
at Object.isRequiredPropType (/node_modules/eslint-plugin-react/lib/util/props.js:91:29)
at /node_modules/eslint-plugin-react/lib/util/propTypes.js:669:54
at iterateProperties (/node_modules/eslint-plugin-react/lib/util/propTypes.js:64:7)
at /node_modules/eslint-plugin-react/lib/util/propTypes.js:664:23
at Array.forEach (<anonymous>)
at DeclarePropTypesForTSTypeAnnotation.convertReturnTypeToPropTypes (/node_modules/eslint-plugin-react/lib/util/propTypes.js:653:34)
at DeclarePropTypesForTSTypeAnnotation.searchDeclarationByName (/node_modules/eslint-plugin-react/lib/util/propTypes.js:562:14)
at DeclarePropTypesForTSTypeAnnotation.visitTSNode (/node_modules/eslint-plugin-react/lib/util/propTypes.js:517:14)
at DeclarePropTypesForTSTypeAnnotation.traverseDeclaredInterfaceOrTypeAlias (/node_modules/eslint-plugin-react/lib/util/propTypes.js:610:14)
at Array.forEach (<anonymous>)
At propTypes.js it goes into the switch case for 'ObjectExpression'
Which fails because the function isRequiredPropType fis called with value which is undefined
It seems to do with the TypeScript parsing in convertReturnTypeToPropTypes(node)
Now, one solution would be to simply change the isRequiredPropType function to return false when undefined is passed, like so:
But I am not entirely sure if there is an underlying problem that caused this issue. From what I can tell this component somehow hit an edge case. The component in question is a function component which is wrapped in a Redux connect() to connect to the translations state.
If the above solution is acceptable I can create a pull request for it, but otherwise I would either need to find time to look into it, or let someone more familiar with the project find the solution :)
The text was updated successfully, but these errors were encountered:
eslint-plugin-react
v7.20.6
causes the following error:At propTypes.js it goes into the switch case for 'ObjectExpression'
with the following values:
Which fails because the function isRequiredPropType fis called with
value
which isundefined
It seems to do with the TypeScript parsing in
convertReturnTypeToPropTypes(node)
Now, one solution would be to simply change the isRequiredPropType function to return false when undefined is passed, like so:
But I am not entirely sure if there is an underlying problem that caused this issue. From what I can tell this component somehow hit an edge case. The component in question is a function component which is wrapped in a Redux connect() to connect to the translations state.
If the above solution is acceptable I can create a pull request for it, but otherwise I would either need to find time to look into it, or let someone more familiar with the project find the solution :)
The text was updated successfully, but these errors were encountered: