Skip to content
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

Removing .value from aliases #575

Closed
nhoizey opened this issue Mar 23, 2021 · 6 comments
Closed

Removing .value from aliases #575

nhoizey opened this issue Mar 23, 2021 · 6 comments

Comments

@nhoizey
Copy link
Contributor

nhoizey commented Mar 23, 2021

If all values have to be defined with value, as explained by @chazzmoney in #119 (comment) , 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.

@dbanksdesign
Copy link
Member

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!

@nhoizey
Copy link
Contributor Author

nhoizey commented Mar 24, 2021

@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.

@phun-ky
Copy link

phun-ky commented Mar 25, 2021

what if you want to alias other stuff than value? 🔥

@frankstallone
Copy link

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.

@chazzmoney
Copy link
Collaborator

Added via #746

@nhoizey
Copy link
Contributor Author

nhoizey commented Jan 7, 2022

@chazzmoney thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants