From 6a7bdf6aee66714d06f6716ae3cdbc6d02c91f2f Mon Sep 17 00:00:00 2001 From: codenamenam Date: Thu, 28 Aug 2025 18:06:03 +0900 Subject: [PATCH] fix: Remove empty curly brackets while verbatimModuleSyntax is on only if default import is used with named import --- src/compiler/transformers/ts.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index cc3da23d2067b..1777974761563 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -2301,7 +2301,10 @@ export function transformTypeScript(context: TransformationContext): Transformer } else { // Elide named imports if all of its import specifiers are elided and settings allow. - const allowEmpty = compilerOptions.verbatimModuleSyntax; + // When a default import exists, avoid keeping empty named braces under verbatimModuleSyntax. + const parentImportClause = node.parent as ImportClause | undefined; + const defaultBindingPresent = !!parentImportClause?.name; + const allowEmpty = compilerOptions.verbatimModuleSyntax && !defaultBindingPresent; const elements = visitNodes(node.elements, visitImportSpecifier, isImportSpecifier); return allowEmpty || some(elements) ? factory.updateNamedImports(node, elements) : undefined; }