Skip to content

Conversation

@vibe-bot-ss
Copy link

Summary

  • Fixed false positive in rule S3403 (different-types-comparison)
  • Issue: Rule incorrectly flagged comparisons involving indexed access types from generic Records
  • Solution: Added check to allow comparisons with unknown types and indexed access types

Details

The rule was raising false positives when comparing indexed access types (e.g., T[K] where T extends Record<string, unknown>) with string literals. Since these types represent unknown values at compile time, they can legitimately be compared with any type using strict equality operators.

Example of Fixed False Positive:

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

  reproduction<Key extends keyof T>(key: Key) {
    return this.foo[key] === 'foo';  // No longer raises FP
  }
}

Test plan

  • Unit tests pass
  • Rulings pass
  • Build passes
  • Added test case for the false positive scenario

Fixes JS-619

🤖 Generated with Claude Code

The rule was incorrectly raising issues when comparing indexed access types
(e.g., T[K] where T extends Record<string, unknown>) with string literals.
These types represent unknown values at compile time and can legitimately
be compared with any type using strict equality operators.

Added check to allow comparisons involving unknown types or indexed access
types. When type information is unknown, prefer not raising an issue.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@jdkandersson jdkandersson marked this pull request as draft December 4, 2025 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant