Skip to content

Commit 99b2d53

Browse files
orktesfkling
authored andcommitted
Ignore SpreadProperties in shapes (#145)
1 parent 4aad1dd commit 99b2d53

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

src/__tests__/__snapshots__/main-test.js.snap

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,19 @@ Object {
7171
"value": "Child.propTypes",
7272
},
7373
},
74+
"extendedChild": Object {
75+
"description": "",
76+
"required": true,
77+
"type": Object {
78+
"name": "shape",
79+
"value": Object {
80+
"adopted": Object {
81+
"name": "bool",
82+
"required": true,
83+
},
84+
},
85+
},
86+
},
7487
"something": Object {
7588
"description": "",
7689
"required": true,

src/__tests__/fixtures/component_4.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ var pt = React.PropTypes;
1919
class Parent extends React.Component {
2020
static propTypes = {
2121
something: pt.string.isRequired,
22-
child: pt.shape(Child.propTypes).isRequired
23-
}
22+
child: pt.shape(Child.propTypes).isRequired,
23+
extendedChild: pt.shape({
24+
...Child.propTypes,
25+
adopted: pt.bool.isRequired
26+
}).isRequired
27+
};
2428
}
2529

2630
export default Parent;

src/utils/getPropType.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ function getPropTypeShape(argumentPath) {
112112
if (types.ObjectExpression.check(argumentPath.node)) {
113113
var value = {};
114114
argumentPath.get('properties').each(function(propertyPath) {
115+
if (propertyPath.get('type').value === types.SpreadProperty.name) {
116+
// It is impossible to resolve a name for a spreadproperty
117+
return;
118+
}
119+
115120
var descriptor: PropDescriptor | PropTypeDescriptor =
116121
getPropType(propertyPath.get('value'));
117122
var docs = getDocblock(propertyPath);

0 commit comments

Comments
 (0)