False positive for S3403 (`different-types-comparison`)

Language: Typescript.

Minimal reproduction case:

class Foo<T extends Record<string, unknown>> {
  constructor(private readonly foo: T) {}

  reproduction<Key extends keyof T>(key: Key) {
    // ESLint: Remove this "===" check; it will always be false. Did you mean to use "=="? (sonarjs/ different-types-comparison)
    return this.foo[key] === 'foo';
  }
}
2 Likes

Hi @Ginden,
Thank you for your report. It is indeed a FP that shouldn’t have been raised. I have created a ticket for this Jira .

Cheers,
Michal