swc-project/swc · error

not implemented

Error message

not implemented

What it means

Inside swc_ecma_utils' identifier-replacement visitor (used when substituting identifiers, e.g. JSX pragma/import rewriting), exit_jsx_object replaces a JSX object identifier like `Foo` in `<Foo.Bar />`. When the replacement value resolves to a JSXNamespacedName (`<ns:name/>`), there is no valid conversion into the JSXObject position, so it panics with unimplemented!().

Solutions

  1. Map the identifier to an identifier or JSXMemberExpr replacement (e.g. `React.Fragment`) instead of a namespaced name
  2. Avoid JSX namespaced names (`<ns:name>`) in code passed through identifier-replacement utilities
  3. Upgrade swc_ecma_utils if a namespaced-name arm has been added

Example fix

// before: replacement map produces a namespaced name
Foo => <a:b /> style JSXNamespacedName

// after: replacement map produces a member expression
Foo => JSX.Member(Foo.Bar)
Defensive patterns

Strategy: validation

Validate before calling

// Before replacing identifiers in JSX, ensure no replacement maps to a namespaced name
for (const [from, to] of replacements) {
  if (isJSXNamespacedName(to)) {
    throw new Error(`Replacement for ${from} is a JSX namespaced name; unsupported`);
  }
}

Prevention

When it happens

Trigger: Rewriting identifiers in code where an identifier used as a JSX object (`<Foo.Bar></Foo.Bar>`) is mapped to a namespaced JSX element name (`<a:b>`), e.g. a custom JSX pragma/alias table that produces namespaced names.

Common situations: Custom JSX runtime/pragma configuration that aliases component namespaces to namespaced names; extremely rare in normal TypeScript/React compiles.

Related errors


AI-assisted analysis of swc-project/swc@5176682b65 (2026-08-17). Data as JSON: /api/errors/5c3b6198132f427a. Report an issue: GitHub.

Appendix: source

Thrown at crates/swc_ecma_utils/src/lib.rs:2564

            }
        };
    }

    pub fn exit_jsx_element_name(&mut self, n: &mut JSXElementName) {
        if let JSXElementName::Ident(ident) = n {
            if let Some(expr) = self.query.query_jsx(ident) {
                *n = expr;
            }
        }
    }

    pub fn exit_jsx_object(&mut self, n: &mut JSXObject) {
        if let JSXObject::Ident(ident) = n {
            if let Some(expr) = self.query.query_jsx(ident) {
                *n = match expr {
                    JSXElementName::Ident(ident) => ident.into(),
                    JSXElementName::JSXMemberExpr(expr) => Box::new(expr).into(),
                    JSXElementName::JSXNamespacedName(..) => unimplemented!(),
                    #[cfg(swc_ast_unknown)]
                    _ => return,
                }
            }
        }
    }

    pub fn exit_object_pat_prop(&mut self, n: &mut ObjectPatProp) {
        if let ObjectPatProp::Assign(AssignPatProp { key, value, .. }) = n {
            if let Some(expr) = self.query.query_lhs(&key.id) {
                let value = value
                    .take()
                    .map(|default_value| {
                        let left = expr.clone().try_into().unwrap();
                        Box::new(default_value.make_assign_to(op!("="), left))
                    })
                    .unwrap_or(expr);

View on GitHub (pinned to 5176682b65)