Consider the following code where I create a "copy" of x
with one of the properties removed, using destructuring:
const x = { a: 1, b: 2, c: 3};
const { a, ...x2} = x;
console.log(x);
console.log(x2);
If I do it like this, @typescript-eslint/no-unused-vars
will consider it an error that a
is not used.
How can I change the code to fix the error, without explicitly asking eslint to ignore the offending line, preferably still using the destructuring syntax? I.e. I really don't want to use delete
, nor do I want to explicitly enumerate all other properties like const x2 = {b: x.b, c: x.c }
.
Is there a fancy syntax or weird eslint rule to have my cake and eat it too?
There is a newly added option named ignoreRestSiblings
for that rule.
You could set it to true to ignore your case:
{ "ignoreRestSiblings": true }