-
Notifications
You must be signed in to change notification settings - Fork 19
feat(tokens): use typescript in the tokens package #5557
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
base: main
Are you sure you want to change the base?
Conversation
|
Related Previews |
|
||
if (meta.layer === 'semantic') { | ||
const baseSetName = meta.setNames[0]; | ||
const overrideSetNameIndex = meta.setNames.findIndex(setName => setName === currentSetName); | ||
const overrideSetNameIndex = meta.setNames.findIndex( | ||
(setName: string) => setName === currentSetName, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, the : string
would not be necessary if options are of the correct type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the :string
is still there
β¦ithub.com/swisspost/design-system into 4499-use-typescript-in-the-tokens-package
@@ -48,7 +49,7 @@ StyleDictionary.registerFormat({ | |||
const utilityTokens = new Map(); | |||
|
|||
dictionary.allTokens.forEach(token => { | |||
const { subitem, state } = token.attributes; | |||
const { subitem, state } = token.attributes || {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This hides the typing error but it doesn't really fix it.
token.attributes
is generally defined as Record<string, unknown>
but we should specify it more to reflect what we get, which is something like this:
attributes: {
category: 'typo',
type: 'post',
item: 'utility',
subitem: 'font-size',
state: '11'
},
], | ||
}); | ||
|
||
config.platforms = Object.entries(config.platforms).reduce( | ||
config.platforms = Object.entries(config.platforms || {}).reduce( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would hide a bug if config.platforms were to not be defined. It might be better to throw an error if config.platforms isn't defined instead. What do you think?
Something like this beforehand:
if (!config.platforms) return;
|
||
if (meta.layer === 'semantic') { | ||
const baseSetName = meta.setNames[0]; | ||
const overrideSetNameIndex = meta.setNames.findIndex(setName => setName === currentSetName); | ||
const overrideSetNameIndex = meta.setNames.findIndex( | ||
(setName: string) => setName === currentSetName, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the :string
is still there
|
π Description
This PR implements Typescript in the Tokens Package.
π Checklist