mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
fixUnusedIdentifier: Delete trailing comma in array binding pattern (#24800)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user