design-tokens / community-group

This is the official DTCG repository for the design tokens specification.
https://tr.designtokens.org
Other
1.56k stars 63 forks source link

Consider using type: "$alias" for explicity #214

Open CristhianParra opened 1 year ago

CristhianParra commented 1 year ago

While creating an alias

{
  "group name": {
    "token name": {
      "$value": 1234,
      "$type": "number"
    }
  },
  "alias name": {
    "$value": "{group name.token name}"
  }
}

I think is more explicit to specify an alias type

{
  "group name": {
    "token name": {
      "$value": 1234,
      "$type": "number"
    }
  },
  "alias name": {
    "$value": "{group name.token name}",
    "$type": "alias"
  }
}

Improving readability, and simplifying the implementation of design/translation/documentation tools

It will also make the following rule more clear

"If no explicit type has been set for a token, tools MUST consider the token invalid and not attempt to infer any other type from the value."

And prevent breaking https://github.com/design-tokens/community-group/issues/139

Since a token without type may be an alias, and therefore, not invalid