Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃 Pick PR #40273 (Fix misplaced comma in auto importe...) into release-4.0 #40303

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/services/codefixes/importFixes.ts
Expand Up @@ -700,7 +700,7 @@ namespace ts.codefix {
}
else if (existingSpecifiers?.length) {
for (const spec of newSpecifiers) {
changes.insertNodeAtEndOfList(sourceFile, existingSpecifiers, spec);
changes.insertNodeInListAfter(sourceFile, last(existingSpecifiers), spec, existingSpecifiers);
}
}
else {
Expand Down
24 changes: 24 additions & 0 deletions tests/cases/fourslash/importNameCodeFix_trailingComma.ts
@@ -0,0 +1,24 @@
/// <reference path="fourslash.ts" />

// Bug #40219 only happens when existing import specifiers are unsorted.

// @Filename: index.ts
//// import {
//// T2,
//// T1,
//// } from "./types";
////
//// const x: T3/**/

// @Filename: types.ts
//// export type T1 = 0;
//// export type T2 = 0;
//// export type T3 = 0;

verify.importFixAtPosition([`import {
T2,
T1,
T3,
} from "./types";

const x: T3`]);