Skip to content

Commit dd10133

Browse files
committed
Fix prop-types crash with Flow spread operator (fixes #1178)
1 parent 7f53bdb commit dd10133

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

lib/rules/prop-types.js

+4
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,10 @@ module.exports = {
678678
switch (propTypes && propTypes.type) {
679679
case 'ObjectTypeAnnotation':
680680
iterateProperties(propTypes.properties, function(key, value) {
681+
if (!value) {
682+
ignorePropsValidation = true;
683+
return;
684+
}
681685
declaredPropTypes[key] = buildTypeAnnotationDeclarationTypes(value);
682686
});
683687
break;

tests/lib/rules/prop-types.js

+14
Original file line numberDiff line numberDiff line change
@@ -1428,6 +1428,20 @@ ruleTester.run('prop-types', rule, {
14281428
'}'
14291429
].join('\n'),
14301430
parser: 'babel-eslint'
1431+
}, {
1432+
code: [
1433+
'type Person = {',
1434+
' ...data,',
1435+
' lastname: string',
1436+
'};',
1437+
'class Hello extends React.Component {',
1438+
' props: Person;',
1439+
' render () {',
1440+
' return <div>Hello {this.props.firstname}</div>;',
1441+
' }',
1442+
'}'
1443+
].join('\n'),
1444+
parser: 'babel-eslint'
14311445
}
14321446
],
14331447

0 commit comments

Comments
 (0)