useNonAdjustedEndPosition when replacing import node (#22517)

* useNonAdjustedEndPosition when replacing import node

* Never adjust positions, and add trivia test
This commit is contained in:
Andy
2018-03-14 11:46:45 -07:00
committed by GitHub
parent 6efc679b9e
commit e7ce3f9457
3 changed files with 7 additions and 6 deletions

View File

@@ -38,6 +38,6 @@ namespace ts.codefix {
}
function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, info: Info): void {
changes.replaceNode(sourceFile, info.importNode, makeImportDeclaration(info.name, /*namedImports*/ undefined, info.moduleSpecifier));
changes.replaceNode(sourceFile, info.importNode, makeImportDeclaration(info.name, /*namedImports*/ undefined, info.moduleSpecifier), textChanges.useNonAdjustedPositions);
}
}

View File

@@ -7,10 +7,10 @@
////export = x;
// @Filename: /b.ts
////import * as [|a|] from "./a";
/////*com ment*/import * as [|a|] from "./a";/*tnem moc*/
// @Filename: /c.ts
////import [|a|] = require("./a");
/////*com ment*/import [|a|] = require("./a");/*tnem moc*/
// @Filename: /d.ts
////import "./a";
@@ -29,7 +29,7 @@ for (const file of ["/b.ts", "/c.ts"]) {
verify.codeFix({
description: "Convert to default import",
newFileContent: `import a from "./a";`,
newFileContent: `/*com ment*/import a from "./a";/*tnem moc*/`,
});
}

View File

@@ -13,6 +13,7 @@
goTo.file("/b.ts");
verify.codeFixAll({
fixId: "useDefaultImport",
// TODO: GH#22337
newFileContent: `import a1 from "./a";import a2 from "./a";`,
newFileContent:
`import a1 from "./a";
import a2 from "./a";`,
});