Closed
Description
TypeScript Version: 2.7.1
Search Terms: infer, compare, equals
Code
type T = [number] | [number, number]; // now t.length has type 1|2
let t: T;
if (t!.length === 0) { // compile error: Operator '===' cannot be applied to types '1' and '0'
}
if (t!.length > 100) { // no compile error
}
if (t!.length === 1 - 1) { // no compile error
}
Expected behavior:
No compile errors on any of these. It's plain inconsistent and not useful.
Actual behavior:
Compile error on t === 0
but not on other comparisons
Playground Link:
See above
Related Issues: