-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support static class getter propTypes #137
Comments
Would like this too, just adding another syntax that is almost similar for completeness: export default class MyComponent extends React.Component {
static propTypes = {
children: PropTypes.node.isRequired,
} |
+1. We actually write things in the latter style for stylistic reasons |
is there any progress on this? |
Static propTypes when defined as a class prop are supported I believe, not sure why the comments state otherwise. This visitor should take care of both cases. visitor: {
ClassProperty(path) {
if (path.node.static && path.node.key.name === 'propTypes')
path.remove();
},
ClassMethod(path) {
if (path.node.static && path.node.key.name === 'propTypes')
path.remove();
}
} |
@sonaye In this case, we miss a test to assert it :) |
Is there any progress on this? I am using this babel plugin but, I still have propTypes that are static fields in my components being transpiled into webpack bundle. |
With classes you can also define your
propTypes
on a static getter property, which this plugin doesn't seem to be able to remove currently.Example:
The text was updated successfully, but these errors were encountered: