From c07f43b6d39392593e58c698bf4eaa07e5c556f7 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Sun, 23 Jun 2024 11:45:45 -0400 Subject: [PATCH] fix: handle removeDefaultImport with type only import --- .../compiler/ast/module/ImportDeclaration.ts | 23 ++++++++++++++----- .../ast/module/importDeclarationTests.ts | 8 +++++++ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/packages/ts-morph/src/compiler/ast/module/ImportDeclaration.ts b/packages/ts-morph/src/compiler/ast/module/ImportDeclaration.ts index 25611c867..381603d03 100644 --- a/packages/ts-morph/src/compiler/ast/module/ImportDeclaration.ts +++ b/packages/ts-morph/src/compiler/ast/module/ImportDeclaration.ts @@ -237,13 +237,24 @@ export class ImportDeclaration extends ImportDeclarationBase { it("should remove it when named imports exists", () => { doTest(`import name, { test } from './file';`, `import { test } from './file';`); }); + + it("should handle import type", () => { + doTest(`import type test from './file';`, `import type {} from './file';`); + }); + + it("should handle import type with named imports", () => { + doTest(`import type test, { other } from './file';`, `import type { other } from './file';`); + }); }); describe(nameof("removeNamespaceImport"), () => {