Cherry-pick PR #40273 into release-4.0 (#40303)

Component commits:
2c0e01aa94 Fix misplaced comma in auto imported specifier

Co-authored-by: Andrew Branch <andrew@wheream.io>
This commit is contained in:
TypeScript Bot 2020-09-14 20:08:51 -04:00 committed by GitHub
parent 3e7a8e7e45
commit 65b84e707e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 1 deletions

View File

@ -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 {

View File

@ -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`]);