mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
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:
parent
cdfa63aa40
commit
75f20f9b65
@ -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() {
|
||||
}`,
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user