Skip to content

Commit 60b4b31

Browse files
jedwards1211ljharb
authored andcommitted
[fix] propTypes: resolveSuperParameterPropsType: add null check
Fixes #2179.
1 parent eeb77f9 commit 60b4b31

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/util/propTypes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ module.exports = function propTypesInstructions(context, components, utils) {
612612
annotation = annotation.typeAnnotation;
613613
}
614614

615-
if (annotation.type === 'GenericTypeAnnotation' && getInTypeScope(annotation.id.name)) {
615+
if (annotation && annotation.type === 'GenericTypeAnnotation' && getInTypeScope(annotation.id.name)) {
616616
return getInTypeScope(annotation.id.name);
617617
}
618618
return annotation;

tests/lib/rules/prop-types.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1805,6 +1805,20 @@ ruleTester.run('prop-types', rule, {
18051805
}
18061806
}
18071807
`,
1808+
settings: {react: {flowVersion: '0.52'}},
1809+
parser: 'babel-eslint'
1810+
}, {
1811+
code: `
1812+
type Props = {
1813+
foo: string,
1814+
};
1815+
1816+
class Bar extends React.Component<Props> {
1817+
render() {
1818+
return <div>{this.props.foo}</div>
1819+
}
1820+
}
1821+
`,
18081822
settings: {react: {flowVersion: '0.53'}},
18091823
parser: 'babel-eslint'
18101824
}, {

0 commit comments

Comments
 (0)