Skip to content

Commit

Permalink
Merge pull request #1529 from jomasti/issue-1499
Browse files Browse the repository at this point in the history
Fix crash in default-props-match-prop-types
  • Loading branch information
ljharb committed Nov 11, 2017
2 parents 02ac5ce + 59e3455 commit e7e2940
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/rules/default-props-match-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ module.exports = {
annotation = findVariableByName(annotation.id.name);
}

if (!annotation || !annotation.properties) {
return properties;
}

return properties.concat(annotation.properties);
}, []);
}
Expand Down
13 changes: 13 additions & 0 deletions tests/lib/rules/default-props-match-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,19 @@ ruleTester.run('default-props-match-prop-types', rule, {
'}'
].join('\n'),
parser: 'babel-eslint'
},
// don't error when variable is not in scope with intersection
{
code: [
'import type ImportedProps from "fake";',
'type Props = ImportedProps & {',
' foo: string',
'};',
'function Hello(props: Props) {',
' return <div>Hello {props.name.firstname}</div>;',
'}'
].join('\n'),
parser: 'babel-eslint'
}
],

Expand Down

0 comments on commit e7e2940

Please sign in to comment.