Skip to content

Commit 4bacad8

Browse files
committed
Fix require-default-props rule filter of undefined exception
1 parent 5827897 commit 4bacad8

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/rules/require-default-props.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ module.exports = {
161161
switch (node.typeAnnotation.type) {
162162
case 'GenericTypeAnnotation':
163163
var annotation = resolveGenericTypeAnnotation(node.typeAnnotation);
164-
properties = annotation ? annotation.properties : [];
164+
properties = annotation && annotation.properties ? annotation.properties : [];
165165
break;
166166

167167
case 'UnionTypeAnnotation':

tests/lib/rules/require-default-props.js

+10
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,16 @@ ruleTester.run('require-default-props', rule, {
677677
'}'
678678
].join('\n'),
679679
parser: 'babel-eslint'
680+
},
681+
{
682+
code: [
683+
'type Props = any;',
684+
685+
'const Hello = function({ foo }: Props) {',
686+
' return <div>Hello {foo}</div>;',
687+
'};'
688+
].join('\n'),
689+
parser: 'babel-eslint'
680690
}
681691
],
682692

0 commit comments

Comments
 (0)