Skip to content

Commit e7e2940

Browse files
authored
Merge pull request jsx-eslint#1529 from jomasti/issue-1499
Fix crash in default-props-match-prop-types
2 parents 02ac5ce + 59e3455 commit e7e2940

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

lib/rules/default-props-match-prop-types.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,10 @@ module.exports = {
177177
annotation = findVariableByName(annotation.id.name);
178178
}
179179

180+
if (!annotation || !annotation.properties) {
181+
return properties;
182+
}
183+
180184
return properties.concat(annotation.properties);
181185
}, []);
182186
}

tests/lib/rules/default-props-match-prop-types.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,19 @@ ruleTester.run('default-props-match-prop-types', rule, {
755755
'}'
756756
].join('\n'),
757757
parser: 'babel-eslint'
758+
},
759+
// don't error when variable is not in scope with intersection
760+
{
761+
code: [
762+
'import type ImportedProps from "fake";',
763+
'type Props = ImportedProps & {',
764+
' foo: string',
765+
'};',
766+
'function Hello(props: Props) {',
767+
' return <div>Hello {props.name.firstname}</div>;',
768+
'}'
769+
].join('\n'),
770+
parser: 'babel-eslint'
758771
}
759772
],
760773

0 commit comments

Comments
 (0)