Skip to content

Commit

Permalink
[fix] propTypes: resolveSuperParameterPropsType: add null check
Browse files Browse the repository at this point in the history
Fixes #2179.
  • Loading branch information
jedwards1211 authored and ljharb committed Apr 10, 2019
1 parent eeb77f9 commit 60b4b31
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/util/propTypes.js
Expand Up @@ -612,7 +612,7 @@ module.exports = function propTypesInstructions(context, components, utils) {
annotation = annotation.typeAnnotation;
}

if (annotation.type === 'GenericTypeAnnotation' && getInTypeScope(annotation.id.name)) {
if (annotation && annotation.type === 'GenericTypeAnnotation' && getInTypeScope(annotation.id.name)) {
return getInTypeScope(annotation.id.name);
}
return annotation;
Expand Down
14 changes: 14 additions & 0 deletions tests/lib/rules/prop-types.js
Expand Up @@ -1805,6 +1805,20 @@ ruleTester.run('prop-types', rule, {
}
}
`,
settings: {react: {flowVersion: '0.52'}},
parser: 'babel-eslint'
}, {
code: `
type Props = {
foo: string,
};
class Bar extends React.Component<Props> {
render() {
return <div>{this.props.foo}</div>
}
}
`,
settings: {react: {flowVersion: '0.53'}},
parser: 'babel-eslint'
}, {
Expand Down

0 comments on commit 60b4b31

Please sign in to comment.