Skip to content

Commit c82746c

Browse files
committed
Fix crash in no-unused-prop-types when encountering impossible intersection flow types (fixes #1806)
1 parent fee2d1a commit c82746c

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/rules/no-unused-prop-types.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,8 @@ module.exports = {
792792
return declarePropTypesForObjectTypeAnnotation(annotation, declaredPropTypes);
793793
}
794794

795-
if (annotation.type === 'UnionTypeAnnotation') {
795+
// Type can't be resolved
796+
if (!annotation.id) {
796797
return true;
797798
}
798799

tests/lib/rules/no-unused-prop-types.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2899,6 +2899,20 @@ ruleTester.run('no-unused-prop-types', rule, {
28992899
`].join('\n'),
29002900
settings: {react: {version: '16.3.0'}},
29012901
parser: 'babel-eslint'
2902+
}, {
2903+
// Impossible intersection type
2904+
code: `
2905+
import React from 'react';
2906+
type Props = string & {
2907+
fullname: string
2908+
};
2909+
class Test extends React.PureComponent<Props> {
2910+
render() {
2911+
return <div>Hello {this.props.fullname}</div>
2912+
}
2913+
}
2914+
`,
2915+
parser: 'babel-eslint'
29022916
}
29032917
],
29042918

0 commit comments

Comments
 (0)