omit defaultProps helper when there are no props

This commit is contained in:
Sebastian McKenzie
2015-11-08 17:10:33 -08:00
parent e6313dec2c
commit da20aa90c1
6 changed files with 13 additions and 8 deletions

View File

@@ -62,7 +62,12 @@ export default function ({ types: t }) {
}
if (isComponent) {
props = t.callExpression(file.addHelper("defaultProps"), [t.memberExpression(type, t.identifier("defaultProps")), props]);
let defProps = t.memberExpression(type, t.identifier("defaultProps"));
if (props.properties.length) {
props = t.callExpression(file.addHelper("defaultProps"), [defProps, props]);
} else {
props = defProps;
}
}
// metadata