Skip to content

Commit 65b84e7

Browse files
TypeScript Botandrewbranch
TypeScript Bot
andauthored
Cherry-pick PR #40273 into release-4.0 (#40303)
Component commits: 2c0e01a Fix misplaced comma in auto imported specifier Co-authored-by: Andrew Branch <andrew@wheream.io>
1 parent 3e7a8e7 commit 65b84e7

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/services/codefixes/importFixes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ namespace ts.codefix {
700700
}
701701
else if (existingSpecifiers?.length) {
702702
for (const spec of newSpecifiers) {
703-
changes.insertNodeAtEndOfList(sourceFile, existingSpecifiers, spec);
703+
changes.insertNodeInListAfter(sourceFile, last(existingSpecifiers), spec, existingSpecifiers);
704704
}
705705
}
706706
else {
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// Bug #40219 only happens when existing import specifiers are unsorted.
4+
5+
// @Filename: index.ts
6+
//// import {
7+
//// T2,
8+
//// T1,
9+
//// } from "./types";
10+
////
11+
//// const x: T3/**/
12+
13+
// @Filename: types.ts
14+
//// export type T1 = 0;
15+
//// export type T2 = 0;
16+
//// export type T3 = 0;
17+
18+
verify.importFixAtPosition([`import {
19+
T2,
20+
T1,
21+
T3,
22+
} from "./types";
23+
24+
const x: T3`]);

0 commit comments

Comments
 (0)