mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 21:36:50 -05:00
useNonAdjustedEndPosition when replacing import node (#22517)
* useNonAdjustedEndPosition when replacing import node * Never adjust positions, and add trivia test
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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*/`,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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";`,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user