Expand composite tokens into individual variables during export#3668
Draft
Expand composite tokens into individual variables during export#3668
Conversation
🦋 Changeset detectedLatest commit: d45a004 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
- Created expandCompositeTokensForVariables utility to expand typography, border, boxShadow, and composition tokens into individual property tokens - Integrated expansion into generateTokensToCreate to ensure composite tokens are expanded before filtering - Added comprehensive tests for the expansion logic - Added test case in updateVariables.test.ts to verify composite tokens are exported correctly Co-authored-by: akshay-gupta7 <9948167+akshay-gupta7@users.noreply.github.com>
- Fixed type assertion in expandCompositeTokensForVariables - Added changeset for the fix - Build and tests passing Co-authored-by: akshay-gupta7 <9948167+akshay-gupta7@users.noreply.github.com>
- Added explicit mapPropertyToTokenType function for safer type mapping - Removed unsafe type assertions - Added comprehensive property-to-type mapping - All tests passing and build successful Co-authored-by: akshay-gupta7 <9948167+akshay-gupta7@users.noreply.github.com>
- Added comprehensive test for typography tokens with paragraph properties - Verified that all TokenTypes enum values are correctly mapped - All 7 tests passing Co-authored-by: akshay-gupta7 <9948167+akshay-gupta7@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix skipping of composite tokens during variable export
Expand composite tokens into individual variables during export
Oct 29, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Composite tokens (typography, border, boxShadow, composition) were being filtered out during variable export because the system only recognized atomic token types.
Changes
New expansion utility (
expandCompositeTokensForVariables): Breaks composite tokens into constituent properties before variable creation. Each property becomes an individually exportable variable with correct type mapping.Integration point: Modified
generateTokensToCreateto expand composites before filtering bytokenTypesToCreateVariable.Type-safe mapping: Added explicit property-to-TokenType mapping to handle conversions from
convertToDefaultPropertyoutput to enum values (e.g.,fontFamily→FONT_FAMILIES,borderWidth→BORDER_WIDTH).Example
A typography token:
{ "heading.large": { "type": "typography", "value": { "fontFamily": "Inter", "fontSize": "24px", "fontWeight": "700" } } }Now exports as three separate variables:
heading.large.fontFamily(string)heading.large.fontSize(number)heading.large.fontWeight(number)Border and boxShadow tokens expand similarly (e.g.,
border.color,shadow.blur).Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.