{"id":"7b29d0db89c40ba7","repo":"rollup/rollup","slug":"not-implemented-cannot-convert-moduledecl-tsname","errorCode":null,"errorMessage":"not implemented: Cannot convert ModuleDecl::TsNamespaceExport","messagePattern":"not implemented: Cannot convert ModuleDecl::TsNamespaceExport","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"rust/parse_ast/src/convert_ast/converter.rs","lineNumber":592,"sourceCode":"      }\n      ModuleDecl::ExportNamed(export_named) => {\n        self.convert_export_named_declaration(export_named, module_item_insert_position)\n      }\n      ModuleDecl::Import(import_declaration) => self.store_import_declaration(import_declaration),\n      ModuleDecl::ExportDefaultExpr(export_default_expression) => self\n        .convert_export_default_expression(export_default_expression, module_item_insert_position),\n      ModuleDecl::ExportAll(export_all) => self.convert_export_all(export_all),\n      ModuleDecl::ExportDefaultDecl(export_default_declaration) => self\n        .convert_export_default_declaration(\n          export_default_declaration,\n          module_item_insert_position,\n        ),\n      ModuleDecl::TsImportEquals(_) => unimplemented!(\"Cannot convert ModuleDecl::TsImportEquals\"),\n      ModuleDecl::TsExportAssignment(_) => {\n        unimplemented!(\"Cannot convert ModuleDecl::TsExportAssignment\")\n      }\n      ModuleDecl::TsNamespaceExport(_) => {\n        unimplemented!(\"Cannot convert ModuleDecl::TsNamespaceExport\")\n      }\n    }\n  }\n\n  pub(crate) fn convert_module_export_name(&mut self, module_export_name: &ModuleExportName) {\n    match module_export_name {\n      ModuleExportName::Ident(identifier) => self.convert_identifier(identifier),\n      ModuleExportName::Str(string_literal) => self.store_literal_string(string_literal),\n    }\n  }\n\n  pub(crate) fn convert_module_item(\n    &mut self,\n    module_item: &ModuleItem,\n    module_item_insert_position: &mut u32,\n  ) {\n    match module_item {\n      ModuleItem::Stmt(statement) => self.convert_statement(statement),","sourceCodeStart":574,"sourceCodeEnd":610,"githubUrl":"https://github.com/rollup/rollup/blob/ddc4ffab628944e45dbb8d66d58aae818015440f/rust/parse_ast/src/convert_ast/converter.rs#L574-L610","documentation":"convert_module_declaration (converter.rs:566) has an unimplemented! arm at line 591 for ModuleDecl::TsNamespaceExport. This is TypeScript's `export as namespace Name` directive that exposes a module as a global. SWC parses it but the buffer format cannot represent it, so the converter panics and Rollup surfaces the message as a parse error.","triggerScenarios":"Source contains `export as namespace React` or `export as namespace MyLib`. The ModuleDecl::TsNamespaceExport node reaches convert_module_declaration with no store arm. Common in UMD-style library declarations.","commonSituations":"Bundling a .ts that declares a UMD/global namespace. Pulling in a library's `.d.ts`-style source that includes the directive. Authoring a library meant to be consumed both as a module and as a global.","solutions":["Add a TypeScript transform plugin (@rollup/plugin-typescript, @rollup/plugin-swc, rollup-plugin-esbuild) that strips `export as namespace` for the bundle target.","Move the directive into a separate `.d.ts` that Rollup ignores rather than bundles.","Remove the line if the global exposure is not needed for the bundle output."],"exampleFix":"// before\nexport as namespace MyLib;\nexport function greet() {}\n\n// after\nexport function greet() {}","handlingStrategy":"validation","validationCode":"// Detect `export as namespace`.\nfunction hasTsNamespaceExport(src) {\n  return /^\\s*export\\s+as\\s+namespace\\s+/m.test(src);\n}\nif (hasTsNamespaceExport(code)) {\n  throw new Error('Source uses `export as namespace`; move to a .d.ts or transpile.');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await rollup({ input });\n} catch (err) {\n  if (String(err.message).includes('ModuleDecl::TsNamespaceExport')) {\n    throw new Error('`export as namespace` reached the native parser; strip it via a TS plugin.');\n  }\n  throw err;\n}","preventionTips":["Keep `export as namespace` in `.d.ts` Rollup does not bundle.","Strip the directive with a TS transform plugin for the bundle target.","Drop it if global exposure is unnecessary for the output."],"tags":["typescript","ast","native-parser","umd","namespace"],"analyzedSha":"ddc4ffab628944e45dbb8d66d58aae818015440f","analyzedAt":"2026-08-03T19:42:57.546Z","schemaVersion":2}