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
Destructuring two variables and reassigning the value of one is hard with let and const #8187
Destructuring two variables and reassigning the value of one is hard with let and const #8187
Comments
The proper way to fix this is: const { name } = props;
let { age } = props; |
Does the |
Sorry, I made an over-simplified example that missed my problem. In the case of using a rest operator, where you want to get an object that is only some properties of an object.
I just tried |
@ericandrewlewis apologies for the delay. Thank you for clarifying your example. I tried it locally and it does indeed report an error, even with the |
🎊 |
Tell us about your environment
What parser (default, Babel-ESLint, etc.) are you using? default
Please show your full configuration:
What did you do? Please include the actual source code causing the issue.
I have a basic test case of the problem in this code:
ESLint says that
let { name, age } = props;
is a problem and should useconst
.Here, two variables are created via destructuring syntax, and one is later reassigned but the other is not.
Fixing the code as the rule suggests means using
const
, which creates a syntax error.What did you expect to happen?
I'm not sure :)
What actually happened? Please include the actual, raw output from ESLint.
The text was updated successfully, but these errors were encountered: