mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
fixUnusedIdentifier: Delete trailing comma in array binding pattern (#24800)
This commit is contained in:
parent
7b2e09263c
commit
855c3a6d4f
@ -228,15 +228,12 @@ namespace ts.codefix {
|
||||
|
||||
case SyntaxKind.BindingElement: {
|
||||
const pattern = (parent as BindingElement).parent;
|
||||
switch (pattern.kind) {
|
||||
case SyntaxKind.ArrayBindingPattern:
|
||||
changes.deleteNode(sourceFile, parent); // Don't delete ','
|
||||
break;
|
||||
case SyntaxKind.ObjectBindingPattern:
|
||||
changes.deleteNodeInList(sourceFile, parent);
|
||||
break;
|
||||
default:
|
||||
return Debug.assertNever(pattern);
|
||||
const preserveComma = pattern.kind === SyntaxKind.ArrayBindingPattern && parent !== last(pattern.elements);
|
||||
if (preserveComma) {
|
||||
changes.deleteNode(sourceFile, parent);
|
||||
}
|
||||
else {
|
||||
changes.deleteNodeInList(sourceFile, parent);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ verify.codeFixAll({
|
||||
x; z;
|
||||
}
|
||||
{
|
||||
const [x,] = o;
|
||||
const [x] = o;
|
||||
x;
|
||||
}
|
||||
{
|
||||
@ -65,7 +65,7 @@ verify.codeFixAll({
|
||||
y;
|
||||
}
|
||||
{
|
||||
const [, y,] = o;
|
||||
const [, y] = o;
|
||||
y;
|
||||
}
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user