Skip to content

Commit d7ee147

Browse files
authored
Ignore children in propTypes (lyft#6)
1 parent db9e687 commit d7ee147

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src/transforms/react-js-make-props-and-state-transform.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,18 @@ export function reactJSMakePropsAndStateInterfaceTransformFactoryFactory(typeChe
223223
return result;
224224
}
225225
const typeValue = getTypeFromReactPropTypeExpression(propertyAssignment.initializer);
226-
const propertySignature = ts.createPropertySignature([], name, undefined, typeValue, undefined);
226+
227+
// Ignore children, React types have it
228+
if (propertyAssignment.name.getText() === 'children') {
229+
return result;
230+
}
231+
const propertySignature = ts.createPropertySignature(
232+
[],
233+
name,
234+
undefined,
235+
typeValue,
236+
undefined,
237+
);
227238
result.members.push(propertySignature)
228239
return result;
229240
}, ts.createTypeLiteralNode([]));

test/react-js-make-props-and-state-transform/static-proptypes-many-props/input.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as React from 'react';
22

33
export default class MyComponent extends React.Component {
44
static propTypes = {
5+
children: React.PropTypes.node,
56
any: React.PropTypes.any,
67
array: React.PropTypes.array,
78
bool: React.PropTypes.bool,
@@ -24,4 +25,4 @@ export default class MyComponent extends React.Component {
2425
render() {
2526
return <div />;
2627
}
27-
}
28+
}

test/react-js-make-props-and-state-transform/static-proptypes-many-props/output.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export default class MyComponent extends React.Component<{
2121
elementRequired: JSX.Element;
2222
}, {}> {
2323
static propTypes = {
24+
children: React.PropTypes.node,
2425
any: React.PropTypes.any,
2526
array: React.PropTypes.array,
2627
bool: React.PropTypes.bool,

0 commit comments

Comments
 (0)