amzn / style-dictionary

A build system for creating cross-platform styles.
https://styledictionary.com
Apache License 2.0
3.94k stars 559 forks source link

fix: .d.ts type issue and resulting type errors #1249

Closed jorenbroekema closed 4 months ago

jorenbroekema commented 5 months ago

https://github.com/microsoft/TypeScript/issues/30511 local .d.ts files are skipped when using skipLibCheck, waiting for TypeScript to allow configuring this a bit better to check local "lib" .d.ts files.

Right now you can temporarily disable skipLibCheck in tsconfig, run lint:types script and filter for the errors coming from our own .d.ts. Fixing the type issue there resulted in a bunch of other type errors, which this PR fixes by introducing a PreprocessedTokens interface where $type property on group level won't exist anymore. This then makes it easier to use in the code when on token group level we know for sure that every prop is either also a token group or a token (both objects).

The PR also comes with a minor fix to remove the group level $type right before user-defined preprocessors, since the $type is delegated to the token level for all tokens. If needed, users can use convertToDTCG utility to delegate the $type from the token level to its farthest common ancestor again, e.g. in format lifecycle.

TODO:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

aws-amplify-us-west-1[bot] commented 5 months ago

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-1249.d16eby4ekpss5y.amplifyapp.com

aws-amplify-us-west-1[bot] commented 5 months ago

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-1249.d1ouz7xofr5p4l.amplifyapp.com