Skip to content

Commit

Permalink
Fix crash in no-unused-prop-types when encountering impossible inters…
Browse files Browse the repository at this point in the history
…ection flow types (fixes #1806)
  • Loading branch information
yannickcr committed Jun 4, 2018
1 parent fee2d1a commit c82746c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/rules/no-unused-prop-types.js
Expand Up @@ -792,7 +792,8 @@ module.exports = {
return declarePropTypesForObjectTypeAnnotation(annotation, declaredPropTypes);
}

if (annotation.type === 'UnionTypeAnnotation') {
// Type can't be resolved
if (!annotation.id) {
return true;
}

Expand Down
14 changes: 14 additions & 0 deletions tests/lib/rules/no-unused-prop-types.js
Expand Up @@ -2899,6 +2899,20 @@ ruleTester.run('no-unused-prop-types', rule, {
`].join('\n'),
settings: {react: {version: '16.3.0'}},
parser: 'babel-eslint'
}, {
// Impossible intersection type
code: `
import React from 'react';
type Props = string & {
fullname: string
};
class Test extends React.PureComponent<Props> {
render() {
return <div>Hello {this.props.fullname}</div>
}
}
`,
parser: 'babel-eslint'
}
],

Expand Down

0 comments on commit c82746c

Please sign in to comment.