-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve typing for ==, != expressions #5840
Conversation
b01bf49
to
e81519b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per chat, add the alternatives considered and rationale for choosing this one for future us to refer to.
} | ||
|
||
possibleOutputs() { | ||
return this.lhs.possibleOutputs().concat(this.rhs.possibleOutputs()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be return [true, false]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦♂️
GL JS change: mapbox/mapbox-gl-js#5840 GL Native issue: #10678
GL JS change: mapbox/mapbox-gl-js#5840 GL Native issue: #10678
Closes #5761
Closes #5835
The overloads of == and != are now effectively:
(T1: Comparable, T2: Comparable) => boolean { T1 == T2 }
(Comparable, value) => boolean
(value, Comparable) => boolean
Where
Comparable = string | number | boolean | null
, and evaluation semantics for thevalue
cases are equivalent to Javascript's strict equality (===
/!==
), i.e., when thevalue
argument's type doesn't match that of theComparable
argument,==
evaluates tofalse
,!=
to true.An alternative, stricter approach we discussed was to keep the signatures above, but to produce an runtime error in the case of a type mismatch between the
value
andComparable
arguments -- essentially inserting a type assertion wrapper around thevalue
argument. We went with the less strict approach because:==
,!=
filters==
/!=
to test fornull
(How to test for nulls with new expression syntax? #5761)