-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed as not planned
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Description
🔎 Search Terms
generics templates comparison compare less-than more-than unknown unsound function inline
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about relational operators and comparisons
⏯ Playground Link
💻 Code
const cmp = <T,>(x: T, y: T) => x < y
null < null
cmp(null, null)
undefined < undefined
cmp(undefined, undefined)
Symbol() < Symbol()
cmp(Symbol(), Symbol())🙁 Actual behavior
Error messages:
- "The value 'null' cannot be used here.(18050)"
- "The value 'undefined' cannot be used here.(18050)"
- "The '<' operator cannot be applied to type 'symbol'.(2469)"
The errors show up for both operands of the relational operator except symbols, which only error on LHS.
The arrow fn cmp doesn't trigger any errors, even at call sites
🙂 Expected behavior
cmp should trigger an error on definition, because even though both params are same-type, they can't always be compared (symbols throw at runtime)
Additional information about the issue
No response
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created