-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Add support for Flow IntersectionTypeAnnotation to prop-types and no-unused-prop-types #1404
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems good. Are there any other rules that would benefit from this awareness?
Hmm - yes, I think that |
Added support to This one was a bit harder because the code is structured completely differently from the other 2 rules, even though the props detection should handle all the same cases... hopefully I can fix that issue soon. 😄 |
props: Props; | ||
static defaultProps = { | ||
foo: "foo", | ||
bar: "bar", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a test case where a defaultProp is omitted for a ?
prop type, and there's no error? Alternatively, you could just remove the defaultProp for "bar" here.
Can confirm that this resolves #1364. Thanks for your work! |
Fixes #1364. Fixes #1323.
The following snippet creates an
IntersectionTypeAnnotation
which was not handled in both rules.I hope the tests/implementation are speaking for themselves on this one 😄 If anyone has any advice for additional test cases please let me know. I didn't test the
React.Component<Props>
syntax because I figured these shouldn't affect that implementation, but perhaps it's worth it?