-
Notifications
You must be signed in to change notification settings - Fork 76
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
New rule: require explicitly typed defaultProps
#169
Comments
I think it would be useful and would be happy to accept a PR! |
I think to do this right, we’d need to use the type checker ( |
Actually, in TypeScript 3.0, you don’t want to explicitly type defaultProps. So, maybe instead of requiring an explicit type, a rule that checks that the inferred type of |
Also see this discussion (which unfortunately currently seems to be on hold): DefinitelyTyped/DefinitelyTyped#28515 |
this sounds like a good idea, but it should now be an eslint rule. see #210 |
It's easy write a component with unsafe defaultProps:
So it's useful to enforce declaring an explicit type for
static defaultProps
(which should basically always bePartial<P>
whereP
is the type of the component’s props), which would catch such silly mistakes:The text was updated successfully, but these errors were encountered: