diff --git a/crates/oxc_isolated_declarations/src/declaration.rs b/crates/oxc_isolated_declarations/src/declaration.rs index a55d7c2041917..be23742cb9145 100644 --- a/crates/oxc_isolated_declarations/src/declaration.rs +++ b/crates/oxc_isolated_declarations/src/declaration.rs @@ -129,8 +129,8 @@ impl<'a> IsolatedDeclarations<'a> { // Follows https://github.com/microsoft/TypeScript/pull/54134 let kind = TSModuleDeclarationKind::Namespace; match body { - TSModuleDeclarationBody::TSModuleDeclaration(decl) => { - let inner = self.transform_ts_module_declaration(decl); + TSModuleDeclarationBody::TSModuleDeclaration(inner_decl) => { + let inner = self.transform_ts_module_declaration(inner_decl); self.ast.alloc_ts_module_declaration( decl.span, decl.id.clone_in(self.ast.allocator), diff --git a/crates/oxc_isolated_declarations/tests/fixtures/nested-namespace-dotted.ts b/crates/oxc_isolated_declarations/tests/fixtures/nested-namespace-dotted.ts new file mode 100644 index 0000000000000..dd27d69d5503e --- /dev/null +++ b/crates/oxc_isolated_declarations/tests/fixtures/nested-namespace-dotted.ts @@ -0,0 +1,15 @@ +// Dotted namespace syntax should preserve all names correctly +export namespace X.Y.Z {} + +// Nested dotted namespaces with content +export namespace A.B.C { + export const value = 1; + export function foo(): void {} +} + +// Deeply nested +export namespace Deep.Nested.Namespace.Structure { + export interface Config { + value: string; + } +} diff --git a/crates/oxc_isolated_declarations/tests/snapshots/nested-namespace-dotted.snap b/crates/oxc_isolated_declarations/tests/snapshots/nested-namespace-dotted.snap new file mode 100644 index 0000000000000..883998f1803ce --- /dev/null +++ b/crates/oxc_isolated_declarations/tests/snapshots/nested-namespace-dotted.snap @@ -0,0 +1,22 @@ +--- +source: crates/oxc_isolated_declarations/tests/mod.rs +input_file: crates/oxc_isolated_declarations/tests/fixtures/nested-namespace-dotted.ts +--- +``` +==================== .D.TS ==================== + +// Dotted namespace syntax should preserve all names correctly +export declare namespace X.Y.Z { + export {}; +} +// Nested dotted namespaces with content +export declare namespace A.B.C { + const value = 1; + function foo(): void; +} +// Deeply nested +export declare namespace Deep.Nested.Namespace.Structure { + interface Config { + value: string; + } +}