Skip to content

Fix baseFontSize alias not resolving per theme when token value is a plain number#3823

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-token-reference-theme-export
Draft

Fix baseFontSize alias not resolving per theme when token value is a plain number#3823
Copilot wants to merge 2 commits intomainfrom
copilot/fix-token-reference-theme-export

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 30, 2026

When baseFontSize references a token that resolves to a plain numeric value (e.g. 16), all themes used the active theme's baseFontSize during export instead of resolving independently per theme. This broke responsive typography workflows relying on per-theme rem→px conversion.

Root cause

getAliasValue returns a number (via checkAndEvaluateMath) for plain numeric token values. The guard in updateVariables.ts only accepted string, silently discarding the per-theme resolved value:

// before — number return from getAliasValue is silently dropped
if (resolvedBaseFontSize && typeof resolvedBaseFontSize === 'string') {
  themeBaseFontSize = resolvedBaseFontSize;
}

// after — accepts both string and number
if (resolvedBaseFontSize !== null && resolvedBaseFontSize !== undefined
  && (typeof resolvedBaseFontSize === 'string' || typeof resolvedBaseFontSize === 'number')) {
  themeBaseFontSize = String(resolvedBaseFontSize);
}

Tokens stored as '16px' (string) already worked; tokens stored as 16 (number) did not.

Changes

  • src/plugin/updateVariables.ts — extend the type guard to accept number returns from getAliasValue when resolving per-theme baseFontSize
  • src/plugin/updateVariables.test.ts — add test covering numeric baseline token values across two themes (1616px, 1818px), verifying 1rem resolves differently per theme rather than using the fallback

💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 30, 2026

🦋 Changeset detected

Latest commit: 6274099

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@tokens-studio/figma-plugin Patch

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 30, 2026

⤵️ 📦 ✨ The artifact was successfully created! Want to test it? Download it here 👀 🎁

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 30, 2026

Commit SHA:cf51ab2524e755580a5f48a48490e456fdfb8b6e

Test coverage results 🧪

Code coverage diff between base branch:main and head branch: copilot/fix-token-reference-theme-export 
Status File % Stmts % Branch % Funcs % Lines
🟢 total 63.04 (0) 54.93 (0.01) 60.12 (0) 63.34 (0)
🟢 packages/tokens-studio-for-figma/src/plugin/updateVariables.ts 96.15 (0) 71.42 (4.76) 100 (0) 96.15 (0)
🟢 packages/tokens-studio-for-figma/src/utils/mapTokensToVariableInfo.ts 100 (0) 87.5 (12.5) 100 (0) 100 (0)

…s plain number

Agent-Logs-Url: https://github.com/tokens-studio/figma-plugin/sessions/9c9f6ea6-6351-4ac9-8dee-5146aee1ec50

Co-authored-by: akshay-gupta7 <9948167+akshay-gupta7@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix token reference in baseFontSize for theme export Fix baseFontSize alias not resolving per theme when token value is a plain number Mar 30, 2026
Copilot AI requested a review from akshay-gupta7 March 30, 2026 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Token reference in baseFontSize no longer resolves per theme during Variables/Styles export

2 participants