mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Fix comment behavior in remove unused named bindings
This commit is contained in:
@@ -128,8 +128,7 @@ namespace ts.codefix {
|
||||
// import d|, { a }| from './file'
|
||||
const previousToken = getTokenAtPosition(sourceFile, namedBindings.pos - 1, /*includeJsDocComment*/ false);
|
||||
if (previousToken && previousToken.kind === SyntaxKind.CommaToken) {
|
||||
const startPosition = textChanges.getAdjustedStartPosition(sourceFile, previousToken, {}, textChanges.Position.FullStart);
|
||||
return [deleteRange({ pos: startPosition, end: namedBindings.end })];
|
||||
return [deleteRange({ pos: previousToken.getStart(), end: namedBindings.end })];
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @noUnusedLocals: true
|
||||
// @Filename: file2.ts
|
||||
//// [| import /* 1 */ A /* 2 */, /* 3 */ { x } from './a'; |]
|
||||
//// console.log(A);
|
||||
|
||||
// @Filename: file1.ts
|
||||
//// export default 10;
|
||||
//// export var x = 10;
|
||||
|
||||
verify.rangeAfterCodeFix("import /* 1 */ A /* 2 */ from './a';");
|
||||
Reference in New Issue
Block a user