Show warning when using unsupported bare value data type#17464
Show warning when using unsupported bare value data type#17464RobinMalfait merged 7 commits intomainfrom
Conversation
| !BARE_VALUE_DATA_TYPES.includes(node.value) | ||
| ) { | ||
| console.warn( | ||
| `Unsupported bare value data type: "${node.value}".\nOnly valid data types are: ${BARE_VALUE_DATA_TYPES.map((x) => `"${x}"`).join(', ')}\n`, |
There was a problem hiding this comment.
@adamwathan do you want to make any changes to this warning?
Output looks something like this right now:
Unsupported bare value data type: "color". Only valid data types are: "number", "integer", "ratio", "percentage" ```css --value([color],color) ^^^^^ ``` There was a problem hiding this comment.
My 5 ct: I don't think the term "bare value" is something that people of that API will be familiar with but maybe we just call it "value data type" (since it's the --value(…) function)?
Unsupported value data type: "color". Only valid data types are: "number", "integer", "ratio", "percentage". ```css --value([color],color) ^^^^^ ``` The rest I think is fine personally but I'd add a dot at the end of the second sentence
There was a problem hiding this comment.
I think people writing plugins like that will be more familiar with the term (or at least should be because they will have to know the difference between color and [color]).
Main reason I used it is because that's what we use in the docs for it: https://tailwindcss.com/docs/adding-custom-styles#bare-values
There was a problem hiding this comment.
Ohh right we do refer to it like that in the docs huh, yep then I think this does make sense
33c8609 to 3fef1e4 Compare …minor) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@tailwindcss/postcss](https://tailwindcss.com) ([source](https://github.com/tailwindlabs/tailwindcss/tree/HEAD/packages/@tailwindcss-postcss)) | [`4.0.17` -> `4.1.3`](https://renovatebot.com/diffs/npm/@tailwindcss%2fpostcss/4.0.17/4.1.3) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | | [tailwindcss](https://tailwindcss.com) ([source](https://github.com/tailwindlabs/tailwindcss/tree/HEAD/packages/tailwindcss)) | [`4.0.17` -> `4.1.3`](https://renovatebot.com/diffs/npm/tailwindcss/4.0.17/4.1.3) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>tailwindlabs/tailwindcss (@​tailwindcss/postcss)</summary> ### [`v4.1.3`](https://github.com/tailwindlabs/tailwindcss/blob/HEAD/CHANGELOG.md#413---2025-04-04) [Compare Source](tailwindlabs/tailwindcss@v4.1.2...v4.1.3) ##### Fixed - Show warning when using unsupported bare value data type in `--value(…)` ([#​17464](tailwindlabs/tailwindcss#17464)) - PostCSS: Ensure changes to the input CSS file don't generate stale output when using Turbopack ([#​17554](tailwindlabs/tailwindcss#17554)) - Ensure classes are detected in Ruby's `%w` syntax in Slim templates ([#​17557](tailwindlabs/tailwindcss#17557)) ### [`v4.1.2`](https://github.com/tailwindlabs/tailwindcss/blob/HEAD/CHANGELOG.md#412---2025-04-03) [Compare Source](tailwindlabs/tailwindcss@v4.1.1...v4.1.2) ##### Fixed - Don't rely on the presence of `@layer base` to polyfill `@property` ([#​17506](tailwindlabs/tailwindcss#17506)) - Support setting multiple inset shadows as arbi...
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
colorto 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.5integer—2ratio—1/2percentage—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.