Skip to content

Commit 75f20f9

Browse files
vpukhanovAndy
authored and
Andy
committed
fixUnusedIdentifier: fix "Remove variable statement" codefix (microsoft#24497)
* fixUnusedIdentifier: fix "Remove variable statement" codefix * Add test for a single "Remove variable statement" codefix in a file
1 parent cdfa63a commit 75f20f9

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/services/codefixes/fixUnusedIdentifier.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace ts.codefix {
2929
}
3030
const delVar = textChanges.ChangeTracker.with(context, t => tryDeleteFullVariableStatement(t, sourceFile, startToken, /*deleted*/ undefined));
3131
if (delVar.length) {
32-
return [createCodeFixAction(fixName, delDestructure, Diagnostics.Remove_variable_statement, fixIdDelete, Diagnostics.Delete_all_unused_declarations)];
32+
return [createCodeFixAction(fixName, delVar, Diagnostics.Remove_variable_statement, fixIdDelete, Diagnostics.Delete_all_unused_declarations)];
3333
}
3434

3535
const token = getToken(sourceFile, textSpanEnd(context.span));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
// @noUnusedLocals: true
4+
5+
////function f() {
6+
//// let a = 1, b = 2, c = 3;
7+
////}
8+
9+
verify.codeFix({
10+
description: "Remove variable statement",
11+
newFileContent:
12+
`function f() {
13+
}`,
14+
});

0 commit comments

Comments
 (0)