tsc TS2367: This comparison appears to be unintentional in CI
TS2367 flags a comparison between two types that can never be equal, so the condition is always false. It often surfaces a typo in a string literal union or a stale enum comparison.
What this error means
tsc fails with "error TS2367: This comparison appears to be unintentional because the types 'A' and 'B' have no overlap." at an === or !== comparison.
src/state.ts:4:7 - error TS2367: This comparison appears to be unintentional because the types
'"open" | "closed"' and '"opened"' have no overlap.
4 if (status === 'opened') {
~~~~~~~~~~~~~~~~~~~Common causes
A literal compared against a value outside its union
The variable is a string-literal union, and the comparison uses a literal (a typo) that is not a member of that union, so they never overlap.
A stale enum or narrowed type comparison
After narrowing, the value can no longer equal the compared constant, so tsc reports the comparison as always-false.
How to fix it
Compare against a valid member
- Read the two types tsc says have no overlap.
- Fix the literal typo so it is a real member of the union.
- Re-run tsc to confirm the comparison can be true.
if (status === 'closed') { /* ... */ }Widen the type if both values are legitimate
If the compared value really can occur, broaden the variable type to include it rather than casting.
type Status = 'open' | 'closed' | 'opened';How to prevent it
- Use string-literal unions and enums so typos in comparisons are caught.
- Let the editor autocomplete literal values.
- Run tsc in strict mode so always-false comparisons surface.