-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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] prop-types
: handle variables defined as props
#2301
Conversation
Co-Authored-By: Jordan Harband <ljharb@gmail.com>
Co-Authored-By: Jordan Harband <ljharb@gmail.com>
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.
Nice. Thanks for taking this task on, it's been on my wish list for a very long time. This likely resolved more issues than just the ones you tagged, so we'll want to do a full review all open no-unused-prop-types
issues and resolve the remaining ones as well. I can help with that once this lands.
Have you done any testing to ensure that double reassignments will still work? ie:
let {a} = props
let b = a;
return <Used thing={b} />
At the very least, that shouldn't throw new any warnings. Might be good to add a test case for that to confirm.
Otherwise LGTM
I'll merge now; we can add more test cases in a followup. |
Fixes #442, fixes #1002, fixes #1257, fixes #1764. (
let {props} = this
)Fixes #833, fixes #1116 (
const Foo = ({ a }) => <>{ a.b }</>
)This pr fixed cases where a variable is defined as
props.**.*
For example:In order to tell weather
foo.a
is a props usage, we need to tell whetherfoo
is defined asprops.**.*
. For that purpose a Map is used.