-
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
Automatically type-annotate arguments to "==", "!=" expressions #5835
Comments
Type inference is performed automatically in most cases, but currently, As an immediate option to simplify your expression a bit, you could use,
|
@anandthakker Thanks, That looks much better. |
* Improve typing for ==, != expressions 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`. * Simplify comparability check * Add internal docs, fix possibleValues
Motivation
After 2 hours of experimentation, I relaised that a simple tag filter looks like this:
["all",["has","amenity"], ["==", ["string",["get", "amenity"]], "toilets"]]
because I have to ensure first that amenity exists, than making its value string, in order to avoid type errors.
This should not be so difficult, and definitely people will not love expresssions, if this very common use case is so difficult to achieve.
Design Alternatives
["==","amenity","toilets"]
I think, this should work out of the box. Because properties is a special object, so I suggest a direct access, and various type issues should not be handled in the forntend code.
(Why on Earth, "get","something" is a Value, when it is in fact a "String"??? :) )
I could get along with:
["==",["get","amenity"],"toilets"]
Design
no idea
Mock-Up
no idea
Concepts
no idea
Implementation
no idea
The text was updated successfully, but these errors were encountered: