If all values have to be defined with value, as explained by @chazzmoney in https://github.com/amzn/style-dictionary/issues/119#issuecomment-526755832 , could .value be removed from the end of all aliases (or made optional, to not break existing ones), as it is used everywhere?
Instead of this:
{
"color": {
"alert": { "value": "red" },
"reference": { "value": "{color.alert.value}" }
}
}
We could write this:
{
"color": {
"alert": { "value": "red" },
"reference": { "value": "{color.alert}" }
}
}
Not a great gain here on an example with one single alias, but nice in a larger code base.
I like this idea, I know it is a pain to write .value all the time. One thing we would need to consider is technically you can reference things that are not tokens. The 'transitive-transforms' example in the 3.0 branch shows one example: https://github.com/amzn/style-dictionary/blob/3.0/examples/advanced/transitive-transforms/tokens/color/core.json5#L13
If there would be a way to do this while not breaking the other types of references I would be all for it!
@dbanksdesign I didn't think about transitive transforms indeed. (They are awesome btw!)
One way would be to try the alias path first, and try with the added .value only if it didn't match.
what if you want to alias other stuff than value? :fire:
How about a build message when it fails due to a missing reference that suggests, "Did you remember to add .value to your reference(s)"? Maybe a band aid but it may be the band aid that Gotham needs, for now. Again, not ideal and as mentioned here you are not always referencing a .value but maybe this helps nudge another idea.
Most helpful comment
@dbanksdesign I didn't think about transitive transforms indeed. (They are awesome btw!)
One way would be to try the alias path first, and try with the added
.valueonly if it didn't match.