Fix comment behavior in remove unused named bindings

This commit is contained in:
Mine Starks 2017-07-11 14:50:55 -07:00
parent bb063f1b5c
commit 80b64de1e4
2 changed files with 13 additions and 2 deletions

View File

@ -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;
}

View File

@ -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';");