Skip to content

Commit 3e85c55

Browse files
committed
Attempt at Flow 0.53 support
1 parent 02ed7d0 commit 3e85c55

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

lib/rules/prop-types.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,12 @@ module.exports = {
917917
}
918918
},
919919

920+
TypeParameterInstantiation: function(node) {
921+
if (node.params && node.params[0].type === 'GenericTypeAnnotation' && node.params[0].id.name === 'Props') {
922+
markPropTypesAsDeclared(node, resolveTypeAnnotation(node));
923+
}
924+
},
925+
920926
VariableDeclarator: function(node) {
921927
const destructuring = node.init && node.id && node.id.type === 'ObjectPattern';
922928
// let {props: {firstname}} = this

tests/lib/rules/prop-types.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,6 +1558,20 @@ ruleTester.run('prop-types', rule, {
15581558
].join('\n'),
15591559
parser: 'babel-eslint'
15601560
},
1561+
{
1562+
code: `
1563+
type Props = {
1564+
foo: string,
1565+
};
1566+
1567+
class Bar extends React.Component<Props> {
1568+
render() {
1569+
return <div>{this.props.foo}</div>
1570+
}
1571+
}
1572+
`,
1573+
parser: 'babel-eslint'
1574+
},
15611575
// issue #1288
15621576
`function Foo() {
15631577
const props = {}

0 commit comments

Comments
 (0)