diff --git a/compiler/src/interop/src/process_lazy_import.ts b/compiler/src/interop/src/process_lazy_import.ts index a7004df8a447ddde221ef738eeabf86233db3a76..dc1d33d555fc97a774729cb5e2e1c62911034b0f 100644 --- a/compiler/src/interop/src/process_lazy_import.ts +++ b/compiler/src/interop/src/process_lazy_import.ts @@ -84,6 +84,9 @@ function updateImportDecl(node: ts.ImportDeclaration, resolver: Object): ts.Impo // case1: import { x } from '...' --> import lazy { x } from '...' // case2: import y, { x } from '...' --> import lazy y, { x } from '...' if (namedBindings && ts.isNamedImports(namedBindings)) { + if (namedBindings.elements.some(e => e.isTypeOnly)) { + return node; + } // The resolver is used to determine whether type symbols need to be processed. // Only TS/ETS files have type symbols. if (resolver) { diff --git a/compiler/src/process_lazy_import.ts b/compiler/src/process_lazy_import.ts index a7004df8a447ddde221ef738eeabf86233db3a76..dc1d33d555fc97a774729cb5e2e1c62911034b0f 100644 --- a/compiler/src/process_lazy_import.ts +++ b/compiler/src/process_lazy_import.ts @@ -84,6 +84,9 @@ function updateImportDecl(node: ts.ImportDeclaration, resolver: Object): ts.Impo // case1: import { x } from '...' --> import lazy { x } from '...' // case2: import y, { x } from '...' --> import lazy y, { x } from '...' if (namedBindings && ts.isNamedImports(namedBindings)) { + if (namedBindings.elements.some(e => e.isTypeOnly)) { + return node; + } // The resolver is used to determine whether type symbols need to be processed. // Only TS/ETS files have type symbols. if (resolver) { diff --git a/compiler/test/ark_compiler_ut/common/process_lazy_import.test.ts b/compiler/test/ark_compiler_ut/common/process_lazy_import.test.ts index 2fc025d0bb67c9d35435f822b90e00ed47021c7e..f5f017e303166495ad3a8af7c707539f60002de9 100644 --- a/compiler/test/ark_compiler_ut/common/process_lazy_import.test.ts +++ b/compiler/test/ark_compiler_ut/common/process_lazy_import.test.ts @@ -47,6 +47,7 @@ const TRANSFORM_LAZY_IMPORT_CODE: string = import test4, { test5 } from "./test4"; import test6, * as ns6 from "./test6"; import type dt from "./test7"; + import { type test8 } from "./test8"; let a: testType = test + t + test2 + testType + ns3.b + test4 + test5 + test6 + ns6.b + dt; let localAbility = new Ability(); let localFeatureAbility = new k(); @@ -67,6 +68,7 @@ const TRANSFORM_LAZY_IMPORT_CODE_EXPECT: string = 'import lazy test4, { test5 } from "./test4";\n' + 'import test6, * as ns6 from "./test6";\n' + 'import type dt from "./test7";\n' + +'import { type test8 } from "./test8";\n' + 'let a: testType = test + t + test2 + testType + ns3.b + test4 + test5 + test6 + ns6.b + dt;\n' + 'let localAbility = new Ability();\n' + 'let localFeatureAbility = new k();\n' +