Skip to content

no-unused-vars: false positive on dotted namespace declarations (export namespace A.B) #21405

@softmarshmallow

Description

@softmarshmallow

Description

eslint(no-unused-vars) produces false positives for dotted/nested TypeScript namespace declarations like export namespace editor.multiplayer { ... }.

The rule incorrectly reports the second (and subsequent) segments of a dotted namespace name as "declared but never used", even though they are part of the namespace declaration syntax, not standalone variable declarations.

Reproduction

// file: example.ts
export namespace editor.multiplayer {
  export type AwarenessPayload = {
    cursor: { x: number; y: number } | null;
  };
}

export namespace editor.api {
  export type Request = { url: string };
}

export namespace editor.internal.export_settings {
  export type Format = "png" | "svg";
}

Running oxlint on this file produces:

× eslint(no-unused-vars): Variable 'multiplayer' is declared but never used.
    ╭─[example.ts:2:25]
  1 │
  2 │ export namespace editor.multiplayer {
    ·                         ─────┬─────
    ·                              ╰── 'multiplayer' is declared here
  3 │   export type AwarenessPayload = {
    ╰────

× eslint(no-unused-vars): Variable 'api' is declared but never used.
    ╭─[example.ts:8:25]
  7 │
  8 │ export namespace editor.api {
    ·                         ─┬─
    ·                          ╰── 'api' is declared here
  9 │   export type Request = { url: string };
    ╰────

× eslint(no-unused-vars): Variable 'internal' is declared but never used.
    ╭─[example.ts:12:25]
 11 │
 12 │ export namespace editor.internal.export_settings {
    ·                         ────┬───
    ·                             ╰── 'internal' is declared here
 13 │   export type Format = "png" | "svg";
    ╰────

Expected behavior

No diagnostic should be emitted for multiplayer, api, or internal — they are segments of the namespace path, not standalone variable declarations.

ESLint's @typescript-eslint/no-unused-vars does not flag these.

Environment

  • oxlint v1.60.0
  • macOS, Node 24 LTS

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions