Skip to content

fix: support nested token declarations in frontmatter#103

Open
vikks wants to merge 2 commits into
google-labs-code:mainfrom
vikks:fix/nested-tokens
Open

fix: support nested token declarations in frontmatter#103
vikks wants to merge 2 commits into
google-labs-code:mainfrom
vikks:fix/nested-tokens

Conversation

@vikks
Copy link
Copy Markdown

@vikks vikks commented Jun 5, 2026

This PR fixes a bug where nested color declarations in the DESIGN.md frontmatter (e.g., background: { light: '#fff', dark: '#000' }) caused validation errors.

Key Changes

  • Recursive Parsing: Implemented a forEachLeaf helper in the ModelHandler to handle arbitrary token nesting depths.
  • Flattened Symbol Table: Nested tokens are now correctly flattened (e.g., colors.background.light) for resolution and validation.
  • Improved Type Safety: Updated ParsedDesignSystem to support nested objects in tokens.
  • Comprehensive Tests: Added unit tests for 2, 3, and 4-level nesting, as well as mixed nested/flat declarations.

Fixes #102\n\n### Update (June 5, 2026)\n- Fixed TypeScript error by expanding ResolvedValue to include number and boolean.\n- Added a token nesting depth limit of 20 levels (MAX_TOKEN_NESTING_DEPTH) to ensure performance and prevent excessive recursion.

  • Made these limits configurable via spec-config.yaml (limits section).

@google-cla
Copy link
Copy Markdown

google-cla Bot commented Jun 5, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@vikks vikks force-pushed the fix/nested-tokens branch from 303b74d to f4fe942 Compare June 5, 2026 06:06
@vikks vikks marked this pull request as ready for review June 5, 2026 06:11
@vikks vikks force-pushed the fix/nested-tokens branch from 8e8abfb to edaf16a Compare June 5, 2026 08:35
@vikks vikks force-pushed the fix/nested-tokens branch from edaf16a to 7a749e9 Compare June 5, 2026 08:48
@vikks vikks changed the title fix: support nested token declarations in frontmatter (#102) fix: support nested token declarations in frontmatter Jun 5, 2026
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.

Nesting of colors produce error.

2 participants