Skip to content

Union error with Flow types #1770

@EdwardDrapkin

Description

@EdwardDrapkin

Seems that if I declare a union type for my props, this plugin dies:

$ eslint --fix src/ test/ Cannot read property 'length' of undefined TypeError: Cannot read property 'length' of undefined at iterateProperties (/Users/edwarddrapkin/projects/flex-mobile-head/node_modules/eslint-plugin-react/lib/rules/prop-types.js:363:22) at declarePropTypesForObjectTypeAnnotation (/Users/edwarddrapkin/projects/flex-mobile-head/node_modules/eslint-plugin-react/lib/rules/prop-types.js:744:7) at propTypes.types.some.annotation (/Users/edwarddrapkin/projects/flex-mobile-head/node_modules/eslint-plugin-react/lib/rules/prop-types.js:783:16) at Array.some (<anonymous>) at declarePropTypesForIntersectionTypeAnnotation (/Users/edwarddrapkin/projects/flex-mobile-head/node_modules/eslint-plugin-react/lib/rules/prop-types.js:766:30) at markPropTypesAsDeclared (/Users/edwarddrapkin/projects/flex-mobile-head/node_modules/eslint-plugin-react/lib/rules/prop-types.js:864:35) at Program:exit.classExpressions.forEach.node (/Users/edwarddrapkin/projects/flex-mobile-head/node_modules/eslint-plugin-react/lib/rules/prop-types.js:1123:13) at Array.forEach (<anonymous>) at Program:exit (/Users/edwarddrapkin/projects/flex-mobile-head/node_modules/eslint-plugin-react/lib/rules/prop-types.js:1121:26) at listeners.(anonymous function).forEach.listener (/Users/edwarddrapkin/projects/flex-mobile-head/node_modules/eslint/lib/util/safe-emitter.js:47:58) error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. 

This type declaration triggers the error:

 type Props = { style: typeof style & StyleObj, isValid: false, errorText: string } | { style: typeof style & StyleObj, isValid: true, caption: string, icon?: Node }; 

This one does not, but is less useful:

type Props = { style: typeof style, isValid: true, errorText?: string, caption?: string, icon?: Node }; 

I'm on version 7.7.0.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions