Skip to content
This repository was archived by the owner on Sep 21, 2019. It is now read-only.

Ignore children in propTypes #6

Merged
merged 1 commit into from
Jul 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/transforms/react-js-make-props-and-state-transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,18 @@ export function reactJSMakePropsAndStateInterfaceTransformFactoryFactory(typeChe
return result;
}
const typeValue = getTypeFromReactPropTypeExpression(propertyAssignment.initializer);
const propertySignature = ts.createPropertySignature([], name, undefined, typeValue, undefined);

// Ignore children, React types have it
if (propertyAssignment.name.getText() === 'children') {
return result;
}
const propertySignature = ts.createPropertySignature(
[],
name,
undefined,
typeValue,
undefined,
);
result.members.push(propertySignature)
return result;
}, ts.createTypeLiteralNode([]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react';

export default class MyComponent extends React.Component {
static propTypes = {
children: React.PropTypes.node,
any: React.PropTypes.any,
array: React.PropTypes.array,
bool: React.PropTypes.bool,
Expand All @@ -24,4 +25,4 @@ export default class MyComponent extends React.Component {
render() {
return <div />;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default class MyComponent extends React.Component<{
elementRequired: JSX.Element;
}, {}> {
static propTypes = {
children: React.PropTypes.node,
any: React.PropTypes.any,
array: React.PropTypes.array,
bool: React.PropTypes.bool,
Expand Down