Skip to content

linter: no-unnecessary-type-arguments false-positives/invalid auto-fix for some Set usecases #20933

@Simek

Description

@Simek

What version of Oxlint are you using?

1.58.0 (0.19.0 oxlint-tsgolint)

What command did you run?

oxlint --type-aware --fix

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

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

What happened?

After latest oxlint and oxlint-tsgolint update there were few new unnecessary type arguments detected, however it looks like ones for empty Set initialization are incorrect (false-positives), i.e:

// typescript-eslint(no-unnecessary-type-arguments): This value can be trivially inferred for this type parameter, so it can be omitted.
const [bookmarkedIds, setBookmarkedIds] = useState<Set<string>>(new Set());
// or
const activeIndexesRef = useRef<Set<number>>(new Set());

In both cases Oxlint auto-fix removes the types (assuming they are correctly inferred), but TSC fails since sets type is set to Set<unknown>:

Type 'Set<unknown>' is not assignable to type 'Set<string>'.

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