- Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
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:
Metadata
Metadata
Assignees
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug