CSF types: fix type checking for components with union props#32102
CSF types: fix type checking for components with union props#32102svenvandescheur wants to merge 3 commits into
Conversation
|
@kasperpeulen Would you mind taking a look? |
Package BenchmarksCommit: No significant changes detected, all good. 👏 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughA type constraint is added to the Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Possibly related PRs
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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 |
|
Hi @svenvandescheur, Thank you for your contribution. Unfortunately, this PR got quite stale since we missed reviewing it. Would you mind resolving the typescript issues? As soon as they're resolved, we'll take a look! |
Closes #25492
Closes #30379
What I did
This PR attempts to fix #25492 by explicitly typing
DecoratorFunction[]to thedecorators?section inArgsFromMetaremoving aneverpath for stories for components with props with union types.Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
I tested the behavior with the following story:
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.tsMake 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.core team members can create a canary release here or locally with
gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>Greptile Summary
This PR fixes a TypeScript type inference issue in the Component Story Format (CSF) where components with union-typed props would fail type checking when used with decorators. The fix modifies the
ArgsFromMetatype by explicitly typing thedecorators?section withDecoratorFunction[], preventing a 'never' type from being incorrectly inferred.The change affects how Storybook handles type checking for components that use advanced TypeScript features like discriminated unions or correlated union types in their props. This improvement ensures that stories can properly use both decorators and union-typed props without TypeScript compilation errors.
Confidence score: 4/5
code/core/src/csf/story.ts: Verify that the type changes don't have unintended consequences for other union type patterns.Summary by CodeRabbit