oxc-project/oxc · error · OxcDiagnostic
Unable to validate computed reference to imported namespace
Error message
Unable to validate computed reference to imported namespace {namespace_name:?}. What it means
Fires from import/namespace when a namespace object is accessed with a computed member expression (ns[key]). Because the key is not a static string, the rule cannot resolve it against the module's export record, so it reports that validation is impossible and recommends a static property access.
Source
Thrown at crates/oxc_linter/src/rules/import/namespace.rs:39
OxcDiagnostic::warn(format!(
"{specifier_name:?} not found in imported namespace {namespace_name:?}."
))
.with_label(span)
}
fn no_export_in_deeply_imported_namespace(
span: Span,
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,View on GitHub (pinned to e1e7af627c)
Solutions
- Use a static property access like `namespace.name` instead of a computed one
- Use a type assertion or eslint-disable comment if dynamic access is required
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/import/namespace.rs:39 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/c680a7eb7fdc1f9c.
Report an issue: GitHub.