Skip to content

Commit 80b64de

Browse files
committed
Fix comment behavior in remove unused named bindings
1 parent bb063f1 commit 80b64de

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/services/codefixes/fixUnusedIdentifier.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ namespace ts.codefix {
128128
// import d|, { a }| from './file'
129129
const previousToken = getTokenAtPosition(sourceFile, namedBindings.pos - 1, /*includeJsDocComment*/ false);
130130
if (previousToken && previousToken.kind === SyntaxKind.CommaToken) {
131-
const startPosition = textChanges.getAdjustedStartPosition(sourceFile, previousToken, {}, textChanges.Position.FullStart);
132-
return [deleteRange({ pos: startPosition, end: namedBindings.end })];
131+
return [deleteRange({ pos: previousToken.getStart(), end: namedBindings.end })];
133132
}
134133
return undefined;
135134
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
// @noUnusedLocals: true
4+
// @Filename: file2.ts
5+
//// [| import /* 1 */ A /* 2 */, /* 3 */ { x } from './a'; |]
6+
//// console.log(A);
7+
8+
// @Filename: file1.ts
9+
//// export default 10;
10+
//// export var x = 10;
11+
12+
verify.rangeAfterCodeFix("import /* 1 */ A /* 2 */ from './a';");

0 commit comments

Comments
 (0)