- Error
- Reported by the type checker
TS2367
This comparison appears to be unintentional because the types '{0}' and '{1}' have no overlap.
A comparison (`===`, `!==`, `==`, `!=`) between two types that can never be equal. It's always true or always false; check the logic.
What it means
When the two operand types have no value in common, the comparison has a fixed result. This usually means a typo in a literal, a comparison already ruled out by earlier narrowing, or comparing values of unrelated types.
Example
type Status = "open" | "closed";
export function isDone(s: Status) {
return s === "done";
}
ts-r-check -p tsconfig.json --pretty false ts-r outputindex.ts(4,10): error TS2367: This comparison appears to be unintentional because the types 'Status' and '"done"' have no overlap.
Recorded by node scripts/verify-examples.mjs with ts-r built from commit 6deaf01. The example uses the default tsconfig: strict, target: es2022, module: esnext, moduleResolution: bundler.
How to fix
- Fix the literal or the variable being compared.
- If earlier code already narrowed the value, remove the redundant check.