fixUnusedIdentifier: fix "Remove variable statement" codefix (#24497)

* fixUnusedIdentifier: fix "Remove variable statement" codefix

* Add test for a single "Remove variable statement" codefix in a file
This commit is contained in:
Vyacheslav Pukhanov authored and Andy committed 2018-05-30 14:51:08 -07:00
1 parent cdfa63aa40
commit 75f20f9b65
2 files changed
+15 -1

No files matched your search

@@ -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));
@@ -0,0 +1,14 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
////function f() {
//// let a = 1, b = 2, c = 3;
////}
verify.codeFix({
description: "Remove variable statement",
newFileContent:
`function f() {
}`,
});