diff --git a/src/services/codefixes/fixUnusedIdentifier.ts b/src/services/codefixes/fixUnusedIdentifier.ts index abff1a5a02f..c97902e7713 100644 --- a/src/services/codefixes/fixUnusedIdentifier.ts +++ b/src/services/codefixes/fixUnusedIdentifier.ts @@ -29,7 +29,7 @@ namespace ts.codefix { } const delVar = textChanges.ChangeTracker.with(context, t => tryDeleteFullVariableStatement(t, sourceFile, startToken, /*deleted*/ undefined)); if (delVar.length) { - return [createCodeFixAction(fixName, delDestructure, Diagnostics.Remove_variable_statement, fixIdDelete, Diagnostics.Delete_all_unused_declarations)]; + return [createCodeFixAction(fixName, delVar, Diagnostics.Remove_variable_statement, fixIdDelete, Diagnostics.Delete_all_unused_declarations)]; } const token = getToken(sourceFile, textSpanEnd(context.span)); diff --git a/tests/cases/fourslash/codeFixUnusedIdentifier_removeVariableStatement.ts b/tests/cases/fourslash/codeFixUnusedIdentifier_removeVariableStatement.ts new file mode 100644 index 00000000000..f57ee074097 --- /dev/null +++ b/tests/cases/fourslash/codeFixUnusedIdentifier_removeVariableStatement.ts @@ -0,0 +1,14 @@ +/// + +// @noUnusedLocals: true + +////function f() { +//// let a = 1, b = 2, c = 3; +////} + +verify.codeFix({ + description: "Remove variable statement", + newFileContent: +`function f() { +}`, +});