Show warning when using unsupported bare value data type #17464
Merged
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
This PR will show a warning if you are using a bare value data type that is not supported.
Let's say you want to create a new utility that allows
color
to be a bare value data type like this:This means that this would enable new syntax that we don't support yet. E.g.:
paint-#0088cc
.The only supported data types for bare values are:
number
—2.5
integer
—2
ratio
—1/2
percentage
—50%
All other data types are not supported in this position. This PR will now show a warning:
Once we have better sourcemap / location tracking support, this warning will point to the exact spot, but for now, only a re-print of the AST can be used.
If you do want to use other data types, then you will have to use arbitrary value syntax with
[…]
instead.This will allow for
paint-[#0088cc]
for example.Note: this is not a behavioral change, we already didn't support other data types, but we silently ignored them. This means that we have to do more parsing at runtime when evaluating the utility.
With this change, a warning is shown when registering the
@utility
, not when using it.