Skip to content

Conversation

@jenny-s51
Copy link
Contributor

@jenny-s51 jenny-s51 commented Sep 2, 2025

Closes patternfly/patternfly-org#4756

What Changed

Adds enum value extraction to tsDocGen.js.

Modified cli/tsDocGen.js to extract enum values from TypeScript union types into clean arrays, making the generated JSON more consumable for LLMs towards the effort to support JSON schemas. This change is essential for patternfly/patternfly-org#4705.

Why This Matters

LLMs currently struggle with union type strings and can generate invalid prop values with our existing approach to parsing. This change provides clean, structured data that will enable accurate code generation via JSON schemas that will support this improvement to our parsing logic for our existing TS components. Clean arrays are fully machine-readable and unambiguous for any AI system.

Current problem: LLM sees "'primary' | 'secondary'" and might generate variant="main"
With this fix: LLM sees ["primary", "secondary"] and generates variant="primary"

Before: "type": "'primary' | 'secondary' | 'tertiary'"
After: "type": "'primary' | 'secondary' | 'tertiary'", "enumValues": ["primary", "secondary", "tertiary"]

Files Changed

  • cli/tsDocGen.js - Added one function (extractEnumValues) and 4 lines to add enumValues field

Testing Instructions

Full Test (2 minutes)

npm install && npm run build:props
grep -A 5 "enumValues" dist/props.json | head -10

What to look for:

  • "enumValues": ["primary", "secondary", ...] arrays in the JSON
  • ✅ All existing props still present (backward compatible)
  • ✅ Original type field unchanged

…t schemas

chore(tsdocgen): update tsdocgen to support enum parsing towards machine readable schemas
@jenny-s51 jenny-s51 merged commit 6b839d8 into patternfly:main Sep 3, 2025
3 checks passed
@github-actions
Copy link

🎉 This PR is included in version 1.13.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update tsDocGen.js to cleanly extract union types into array values

2 participants