Skip to content

linter: no-unnecessary-type-arguments fixer breaks on functions w/ signature overloads #21096

@zachkirsch

Description

@zachkirsch

What version of Oxlint are you using?

1.58.0

What command did you run?

oxlint

What does your .oxlintrc.json (or oxlint.config.ts) config file look like?

  ...
  "rules": {
    "typescript/no-unnecessary-type-arguments": "error",
  }
  ...

What happened?

Noticed a bug in typescript/no-unnecessary-type-arguments where if I apply the fixer, my code doesn't compile:

declare function fn<T, I>(init: I, toT: (arg: I) => T): T;
declare function fn<T>(init: T): T;

// The explicit `undefined` selects the 2-type-param overload.
// The fixer removes it → `f<string>(undefined, () => "ok")` → matches the 1-type-param
// overload where `init: T` requires `string`, so `undefined` is a type error.
const x = fn<string, undefined>(undefined, () => "ok");

Metadata

Metadata

Assignees

Labels

Type

Priority

None yet

Effort

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions