-
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
Automatic string coercion for "concat" and text-field #6190
Comments
This is only really an issue for |
Mostly, but also effects image properties. For example, stylesheets often compose the name of a sprite image by looking at the # of characters in a data field. Would be nicer to be able to write |
I think that would be an issue with expression-jamsession? |
Ah, that doesn't work. Okay, let's expand this to a request for |
It would be great to add automatic string coercion *-image values as well as text-field. |
This has also come up as a point of confusion for iOS developers, though the examples I’ve seen could’ve been mitigated through clearer documentation and error messages at the time. |
@mapbox/gl-core automatic type coercion for text-field and image properties would solve some usability issues that have been recurring in Studio, so it would be amazing to see movement on this issue soon. |
I implemented auto-coercion for
In other words, treat the string type more like the color type, with implicit conversions rather than implicit assertions. But that feels like a more fundamental shift in our thinking than what's been previously proposed. I'm pretty sure we don't want to go down the path of making every type implicitly convertible, so I'd like to have a cogent argument why string is special. |
Some examples of undesirable results if we always did implicit conversion for strings:
Not sure if this is worse than the confusion that might be caused by having sometimes auto-coercion / sometimes assertion 🤔 |
The examples in #6190 (comment) point to a possible need for a distinction between |
Looking at the various examples and counter-examples posted here, I think a reasonable compromise could be to coerce values to the expected type if we can deduce that type from the function. E.g. for
Is there any reason to not add an automatic string coercion for the |
A related issue I've come across in styles that use Mapbox Streets data: We are getting these warnings thrown: ...because it is common for
I think this would solve our issues 👍 |
mapbox-gl-js version:
0.44
It is common to want to use numbers as strings, especially in the
text-field
input. One use-case is to display number values on contour lines. This doesn't work:The proper expression is as follows:
For all users, this is pretty confusing, and doesn't seem necessary:
to-string
, but it adds complexity and just feels unnecessary.The text was updated successfully, but these errors were encountered: