{"id":"bce0038cb5731fbc","repo":"rollup/rollup","slug":"not-implemented-cannot-convert-decl-tsenum","errorCode":null,"errorMessage":"not implemented: Cannot convert Decl::TsEnum","messagePattern":"not implemented: Cannot convert Decl::TsEnum","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"rust/parse_ast/src/convert_ast/converter.rs","lineNumber":282,"sourceCode":"    match declaration {\n      Decl::Var(variable_declaration) => {\n        self.store_variable_declaration(&VariableDeclaration::Var(variable_declaration))\n      }\n      Decl::Fn(function_declaration) => self.convert_function(\n        &function_declaration.function,\n        &TYPE_FUNCTION_DECLARATION,\n        Some(&function_declaration.ident),\n      ),\n      Decl::Class(class_declaration) => self.store_class_declaration(\n        class_declaration,\n        outside_class_span_decorators_insert_position,\n      ),\n      Decl::Using(using_declaration) => {\n        self.store_variable_declaration(&VariableDeclaration::Using(using_declaration))\n      }\n      Decl::TsInterface(_) => unimplemented!(\"Cannot convert Decl::TsInterface\"),\n      Decl::TsTypeAlias(_) => unimplemented!(\"Cannot convert Decl::TsTypeAlias\"),\n      Decl::TsEnum(_) => unimplemented!(\"Cannot convert Decl::TsEnum\"),\n      Decl::TsModule(_) => unimplemented!(\"Cannot convert Decl::TsModule\"),\n    }\n  }\n\n  fn convert_export_named_declaration(\n    &mut self,\n    export_named_declaration: &NamedExport,\n    module_item_insert_position: &mut u32,\n  ) {\n    match export_named_declaration.specifiers.first() {\n      Some(ExportSpecifier::Namespace(export_namespace_specifier)) => self\n        .store_export_all_declaration(\n          &export_named_declaration.span,\n          export_named_declaration.src.as_ref().unwrap(),\n          &export_named_declaration.with,\n          Some(&export_namespace_specifier.name),\n        ),\n      None | Some(ExportSpecifier::Named(_)) => self.store_export_named_declaration(","sourceCodeStart":264,"sourceCodeEnd":300,"githubUrl":"https://github.com/rollup/rollup/blob/ddc4ffab628944e45dbb8d66d58aae818015440f/rust/parse_ast/src/convert_ast/converter.rs#L264-L300","documentation":"The native Rust converter has no path for TypeScript `enum` declarations. Hitting `Decl::TsEnum` panics via `unimplemented!`. Unlike type-only constructs, enums have runtime values and need a real transform, which the native parser does not perform.","triggerScenarios":"A `.ts` file containing `enum Color { Red, Green, Blue }` parsed natively by Rollup without a transpile plugin.","commonSituations":"Using enums in source fed directly to Rollup; assuming Rollup handles enums natively; large TS codebases that pervasively use enums.","solutions":["Add `@rollup/plugin-typescript` or `@rollup/plugin-swc` to transform enums before parsing.","Replace enums with `const` objects (`const Color = { Red: 0, Green: 1 } as const`).","Pre-compile `.ts` to `.js` and bundle the JS instead."],"exampleFix":"// before\nenum Color { Red, Green, Blue }\n\n// after\nconst Color = { Red: 0, Green: 1, Blue: 2 } as const;","handlingStrategy":"fallback","validationCode":"// Detect enum declarations before the native parser sees them.\nconst ENUM_RE = /\\benum\\s+\\w+/;\nfunction containsEnumDecl(code) {\n  return ENUM_RE.test(code);\n}","typeGuard":null,"tryCatchPattern":"// Fall back to a TS transform plugin on enum panic.\ntry { await rollup(opts); }\ncatch (err) {\n  if (/Cannot convert Decl::TsEnum/.test(err.message)) {\n    opts.plugins = [swc({ ts: true }), ...(opts.plugins ?? [])];\n    await rollup(opts);\n  } else throw err;\n}","preventionTips":["Transform enums with @rollup/plugin-typescript or @rollup/plugin-swc.","Prefer `const` objects (`as const`) over `enum` for bundler-friendlier output.","Pre-compile .ts to .js if your pipeline cannot add a TS plugin."],"tags":["rust","ast","typescript","parser","panic","enum"],"analyzedSha":"ddc4ffab628944e45dbb8d66d58aae818015440f","analyzedAt":"2026-08-03T19:42:57.546Z","schemaVersion":2}