Babel plugin for removing static declarations of React propTypes
on classes.
Input:
// MyComponent extends React.Component
MyComponent.propTypes = {
someString: React.PropTypes.string.isRequired,
someBoolean: React.PropTypes.bool
};
Output:
// Declaration is maintained in case other code references this propTypes object
MyComponent.propTypes = {};
The plugin can be used to remove PropTypes from production environments, where they have no effect.
$ npm install babel-plugin-remove-proptypes
{
"plugins": ["remove-proptypes"]
}
$ babel --plugins remove-proptypes script.js
require('babel-core').transform('code', {
plugins: ['remove-proptypes']
});