From 60b4b31d13744ff692e3422230291a04baa15fcb Mon Sep 17 00:00:00 2001 From: Andy Edwards Date: Wed, 10 Apr 2019 15:35:20 -0500 Subject: [PATCH] [fix] `propTypes`: resolveSuperParameterPropsType: add null check Fixes #2179. --- lib/util/propTypes.js | 2 +- tests/lib/rules/prop-types.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/util/propTypes.js b/lib/util/propTypes.js index 283e969284..8d47b2563b 100644 --- a/lib/util/propTypes.js +++ b/lib/util/propTypes.js @@ -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; diff --git a/tests/lib/rules/prop-types.js b/tests/lib/rules/prop-types.js index a16ad51293..d33363bec6 100755 --- a/tests/lib/rules/prop-types.js +++ b/tests/lib/rules/prop-types.js @@ -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 { + render() { + return
{this.props.foo}
+ } + } + `, settings: {react: {flowVersion: '0.53'}}, parser: 'babel-eslint' }, {