mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 11:54:44 -06:00
Fix comment behavior in remove unused named bindings
This commit is contained in:
parent
bb063f1b5c
commit
80b64de1e4
@ -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;
|
||||
}
|
||||
|
||||
12
tests/cases/fourslash/unusedImports14FS.ts
Normal file
12
tests/cases/fourslash/unusedImports14FS.ts
Normal 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';");
|
||||
Loading…
x
Reference in New Issue
Block a user