Skip to content

linter: no-unused-vars false positive w/TS overload #5406

@eventualbuddha

Description

@eventualbuddha

no-unused-vars warns on the following code:

export function log(message: string, ...interpolations: unknown[]): void;
export function log(message: string, ...interpolations: unknown[]): void {
  console.log(message, interpolations);
}

It claims interpolations in the overload signature is unused. However, it only makes sense to check for unused vars in functions with bodies. Here's the output:

❯ npx oxlint@latest test.ts

  ⚠ eslint(no-unused-vars): Variable 'interpolations' is declared but never used.
   ╭─[test.ts:1:38]
 1 │ export function log(message: string, ...interpolations: unknown[]): void;
   ·                                      ──────────────┬─────────────
   ·                                                    ╰── 'interpolations' is declared here
 2 │ export function log(message: string, ...interpolations: unknown[]): void {
   ╰────
  help: Consider removing this declaration.

Finished in 84ms on 1 file with 93 rules using 3 threads.
Found 1 warning and 0 errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linterArea - LinterC-bugCategory - Buggood first issueExperience Level - Good for newcomers

    Type

    No type

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions