Controls: Resolve select control inference for optional unions exceeding 28 elements#35354
Controls: Resolve select control inference for optional unions exceeding 28 elements#35354Ranit-dev2004 wants to merge 1 commit into
Conversation
|
📝 WalkthroughWalkthroughThe ChangesInfer Controls Update
Estimated code review effort: 1 (Trivial) | ~5 minutes Estimated code review effort: 1 (Trivial) | ~5 minutes Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
code/core/src/preview-api/modules/store/inferControls.ts (1)
68-82: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider typing the fallback token instead of
any.
(type as any).valuebypasses type safety, whereas theenumcase above usestype as SBEnumType. A narrower local type (or extendingSBEnumType) for the fallback token would preserve type checking forvalueList.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@code/core/src/preview-api/modules/store/inferControls.ts` around lines 68 - 82, The fallback branch in inferControls currently uses (type as any).value, which bypasses type safety and should be narrowed. Update the default case to use a typed local shape or extend SBEnumType for the fallback token so valueList is checked properly, and keep the existing select/options logic intact while removing the any cast.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@code/core/src/preview-api/modules/store/inferControls.ts`:
- Around line 68-82: The fallback branch in inferControls currently uses (type
as any).value, which bypasses type safety and should be narrowed. Update the
default case to use a typed local shape or extend SBEnumType for the fallback
token so valueList is checked properly, and keep the existing select/options
logic intact while removing the any cast.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: efc015d8-6b9c-4854-845e-cb8b1fece631
📒 Files selected for processing (1)
code/core/src/preview-api/modules/store/inferControls.ts
Closes #12641
What I did
Fixes an issue where large optional TypeScript union types that exceed docgen token limits fallback to broad type definitions, causing Storybook to fall back to a raw text or object control instead of mapping to an interactive
selectdropdown.Changes
defaultfallback switch case withininferControls.ts.isUnionListverification helper to safely capture the inner array elements from the fallback token payload.selectcontrol with a fallback value filtering mechanism.Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
TsTypes).Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal,ci:mergedorci:dailyGH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli-storybook/src/sandbox-templates.tsDeclare whether manual QA will be needed for this PR during the next release, through
qa:neededorqa:skipMake sure this PR contains one of the labels below:
Available labels
bug: Internal changes that fixes incorrect behavior.maintenance: User-facing maintenance tasks.dependencies: Upgrading (sometimes downgrading) dependencies.build: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup: Minor cleanup style change. Will not show up in release changelog.documentation: Documentation only changes. Will not show up in release changelog.feature request: Introducing a new feature.BREAKING CHANGE: Changes that break compatibility in some way with current major version.other: Changes that don't fit in the above categories.🦋 Canary release
This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the
@storybookjs/coreteam here.Summary by CodeRabbit
New Features
Bug Fixes