Error AtlasError Documentation and Resolution

TypeScript thinks the comparison appears to be unintentional

error TS2367: This comparison appears to be unintentional because the types 'X' and 'Y' have no overlap.

TypeScript determined that the compared values cannot both satisfy the condition because their types do not overlap in a way that makes the comparison meaningful.

error TS2367: This comparison appears to be unintentional because the types 'X' and 'Y' have no overlap.
  • The comparison uses values whose types can never overlap.
  • Literal or union types were narrowed in a way that makes the condition impossible.
  • The wrong variable or enum member is being compared in the condition.
  1. Inspect the compared values and confirm the condition is logically possible.
  2. Correct the types or literals used in the comparison.
  3. Refactor the control flow if the intended condition requires different narrowing.
TypeScript Docs: Narrowing
TS2367 comparison appears to be unintentional: causes and fixes | Error Atlas