Skip to content

[restrict-plus-operands] False positive when using Extract and generics #431

Closed
@boris-petrov

Description

@boris-petrov

I'm using the latest version of all packages (1.6.0).

function x<T>(z: Extract<keyof T, string>): string {
  return z + '__';
}

This warns that the addition is unsafe but it shouldn't. It works correctly if it's not keyof T but keyof obj where obj is some object, i.e. generics are not involved.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomerspackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions