diff --git a/src/services/organizeImports.ts b/src/services/organizeImports.ts index be0392a3eba..142bdbe8791 100644 --- a/src/services/organizeImports.ts +++ b/src/services/organizeImports.ts @@ -237,7 +237,9 @@ namespace ts.OrganizeImports { ? createNamedImports(sortedImportSpecifiers) : updateNamedImports(namedImports[0].importClause!.namedBindings as NamedImports, sortedImportSpecifiers); // TODO: GH#18217 - // Type-only imports are not allowed to combine + // Type-only imports are not allowed to mix default, namespace, and named imports in any combination. + // We could rewrite a default import as a named import (`import { default as name }`), but we currently + // choose not to as a stylistic preference. if (isTypeOnly && newDefaultImport && newNamedImports) { coalescedImports.push( updateImportDeclarationAndClause(importDecl, newDefaultImport, /*namedBindings*/ undefined)); diff --git a/src/testRunner/unittests/services/organizeImports.ts b/src/testRunner/unittests/services/organizeImports.ts index 149ed1d04b2..6627616a67d 100644 --- a/src/testRunner/unittests/services/organizeImports.ts +++ b/src/testRunner/unittests/services/organizeImports.ts @@ -186,6 +186,8 @@ namespace ts { `import type { x } from "lib";`, `import type * as y from "lib";`, `import type z from "lib";`); + // Default import could be rewritten as a named import to combine with `x`, + // but seems of debatable merit. const actualCoalescedImports = OrganizeImports.coalesceImports(sortedImports); const expectedCoalescedImports = actualCoalescedImports; assertListEqual(actualCoalescedImports, expectedCoalescedImports);