Skip to content

Commit 4097874

Browse files
author
Paul van Brenk
committed
Fix 'import a = A' case
1 parent 1f94e14 commit 4097874

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/services/codefixes/unusedIdentifierFixes.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,11 @@ namespace ts.codefix {
9191
return removeSingleItem(elements, token);
9292
}
9393

94+
// handle case where 'import a = A;'
95+
// remove entire line
9496
case SyntaxKind.ImportEqualsDeclaration:
95-
return createCodeFix("{}", token.pos, token.end - token.pos);
97+
const importDecl = token.parent;
98+
return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos);
9699

97100
case SyntaxKind.EnumDeclaration:
98101
return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos);

tests/cases/fourslash/unusedImports10FS.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
//// [|import a = A;|]
1313
//// }
1414

15-
verify.codeFixAtPosition(" import {} = A;");
15+
verify.codeFixAtPosition("");
1616

tests/cases/fourslash/unusedImports9FS.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
////
1818
//// }
1919

20-
verify.codeFixAtPosition("import {} = require('./file1')");
20+
verify.codeFixAtPosition("");

0 commit comments

Comments
 (0)