oxc-project/oxc · error · OxcDiagnostic

Assignment to member of namespace {namespace_name:?}.'

Error message

Assignment to member of namespace {namespace_name:?}.'

What it means

Fires from import/namespace when code assigns to a member of an imported namespace object (e.g. ns.foo = 1). ES module namespaces are read-only, so the assignment helper flags the target span with the namespace name.

Source

Thrown at crates/oxc_linter/src/rules/import/namespace.rs:47

    specifier_name: &str,
    namespace_name: &str,
) -> OxcDiagnostic {
    OxcDiagnostic::warn(format!(
        "{specifier_name:?} not found in deeply imported namespace {namespace_name:?}."
    ))
    .with_label(span)
}

fn computed_reference(span: Span, namespace_name: &str) -> OxcDiagnostic {
    OxcDiagnostic::warn(format!(
        "Unable to validate computed reference to imported namespace {namespace_name:?}."
    ))
    .with_help("Use a static property access (e.g. `namespace.name`) instead of a computed one.")
    .with_label(span)
}

fn assignment(span: Span, namespace_name: &str) -> OxcDiagnostic {
    OxcDiagnostic::warn(format!("Assignment to member of namespace {namespace_name:?}.'"))
        .with_help("Imported namespace members are read-only. Assign to a local variable instead.")
        .with_label(span)
}

// <https://github.com/import-js/eslint-plugin-import/blob/v2.29.1/docs/rules/namespace.md>
#[derive(Debug, Default, Clone, JsonSchema, Deserialize)]
#[serde(rename_all = "camelCase", default, deny_unknown_fields)]
pub struct Namespace {
    /// Whether to allow computed references to an imported namespace.
    allow_computed: bool,
}

declare_oxc_lint!(
    /// ### What it does
    ///
    /// Enforces names exist at the time they are dereferenced, when imported as
    /// a full namespace (i.e. `import * as foo from './foo'; foo.bar();` will
    /// report if bar is not exported by `./foo.`).  Will report at the import

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Remove the assignment to the namespace member
  2. Create a local mutable copy of the value if mutation is needed
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/oxc_linter/src/rules/import/namespace.rs:47 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20). Data as JSON: /api/errors/5ef66f9b30710228. Report an issue: GitHub.