Core: Add parameter typings for addon-pseudo-state#32384
Conversation
bf82332 to
fb50aaf
Compare
|
View your CI Pipeline Execution ↗ for commit f6ae955
☁️ Nx Cloud last updated this comment at |
Package BenchmarksCommit: The following packages have significant changes to their size or dependencies:
|
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 532 | 532 | 0 |
| Self size | 751 KB | 751 KB | 🎉 -37 B 🎉 |
| Dependency size | 58.57 MB | 58.50 MB | 🎉 -65 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/nextjs-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 124 | 124 | 0 |
| Self size | 3.90 MB | 3.83 MB | 🎉 -65 KB 🎉 |
| Dependency size | 21.61 MB | 21.54 MB | 🎉 -65 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/react-native-web-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 157 | 157 | 0 |
| Self size | 31 KB | 31 KB | 🚨 +24 B 🚨 |
| Dependency size | 22.99 MB | 22.93 MB | 🎉 -65 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/react-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 114 | 114 | 0 |
| Self size | 37 KB | 37 KB | 0 B |
| Dependency size | 19.55 MB | 19.48 MB | 🎉 -65 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/react-webpack5
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 272 | 272 | 0 |
| Self size | 25 KB | 25 KB | 0 B |
| Dependency size | 43.52 MB | 43.46 MB | 🎉 -65 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/react
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 2 | 2 | 0 |
| Self size | 695 KB | 629 KB | 🎉 -65 KB 🎉 |
| Dependency size | 28 KB | 28 KB | 🚨 +6 B 🚨 |
| Bundle Size Analyzer | Link | Link |
8b8fd97 to
7977df3
Compare
|
@Sidnioulz Can you take another look? |
7977df3 to
e073b37
Compare
📝 WalkthroughWalkthroughExtracted pseudo-state types into a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes ✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
code/addons/pseudo-states/src/constants.ts(0 hunks)code/addons/pseudo-states/src/index.ts(1 hunks)code/addons/pseudo-states/src/preview/withPseudoState.ts(1 hunks)code/addons/pseudo-states/src/types.test-d.ts(1 hunks)code/addons/pseudo-states/src/types.ts(1 hunks)code/addons/pseudo-states/vitest.config.ts(1 hunks)
💤 Files with no reviewable changes (1)
- code/addons/pseudo-states/src/constants.ts
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Adhere to ESLint and Prettier rules across all JS/TS source files
Files:
code/addons/pseudo-states/src/index.tscode/addons/pseudo-states/vitest.config.tscode/addons/pseudo-states/src/types.test-d.tscode/addons/pseudo-states/src/types.tscode/addons/pseudo-states/src/preview/withPseudoState.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Fix type errors and prefer precise typings instead of using any or suppressions, consistent with strict mode
Files:
code/addons/pseudo-states/src/index.tscode/addons/pseudo-states/vitest.config.tscode/addons/pseudo-states/src/types.test-d.tscode/addons/pseudo-states/src/types.tscode/addons/pseudo-states/src/preview/withPseudoState.ts
🧬 Code graph analysis (3)
code/addons/pseudo-states/src/index.ts (1)
code/addons/pseudo-states/src/types.ts (1)
PseudoTypes(22-24)
code/addons/pseudo-states/src/types.test-d.ts (1)
code/core/src/csf/csf-factories.ts (1)
definePreview(38-62)
code/addons/pseudo-states/src/types.ts (2)
code/addons/pseudo-states/src/constants.ts (1)
PSEUDO_STATES(34-43)code/addons/pseudo-states/src/index.ts (1)
PseudoTypes(8-8)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: normal
- GitHub Check: Core Unit Tests, windows-latest
🔇 Additional comments (5)
code/addons/pseudo-states/vitest.config.ts (1)
8-12: LGTM!Enabling type checking correctly supports the new type-level tests introduced in
types.test-d.ts.code/addons/pseudo-states/src/types.test-d.ts (1)
11-45: LGTM!The type tests correctly validate the pseudo-state parameter types using negative cases (invalid value/key) and positive cases (valid config).
code/addons/pseudo-states/src/index.ts (1)
4-10: LGTM!The type export and generic parameterization correctly expose the pseudo-state types for CSF4 integration and IntelliSense support.
code/addons/pseudo-states/src/preview/withPseudoState.ts (1)
16-16: LGTM!The import consolidation correctly centralizes type definitions without altering runtime behavior.
code/addons/pseudo-states/src/types.ts (1)
1-24: LGTM!The type definitions correctly model the pseudo-state parameter API and align with the runtime behavior in
withPseudoState.ts. The JSDoc link provides helpful documentation context.
Should be good to go if CI's green, thanks for the reminder! I hadn't caught Bill's new commits. |
|
@mrginglymus updating your branch as I think the CI errors we see are caused by issues on |
|
Well that was an odd one. Looks like enabling type testing in the pseudo addon meant a different? stricter? type checker was running over the stories in the addon - I can only assume so, as that's the only way the react renderer might be pulled in. Because we're pointing at the source files, we check the types of all the internals there too including assignment to globalThis. The typings for that are in Either way, sticking an import in the test file seemed to fix it. I was going to add a @Sidnioulz hopefully this will now be green |
What I did
Export types for adodn-pseudo parameters and add to preview definition for typing in csf4.
Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!
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
Updated On: 2025-09-03 10:31:08 UTC
This PR enhances TypeScript support for the
addon-pseudo-statesby adding comprehensive parameter typings for CSF4 (Component Story Format 4) integration. The changes reorganize type definitions by moving thePseudoStatetype fromconstants.tsto a new dedicatedtypes.tsfile, which now contains a complete type system includingPseudoStateConfig,PseudoParameter,PseudoParameters, andPseudoTypesinterfaces.The new type system enables proper IntelliSense and type checking when configuring pseudo-state parameters in stories. The
PseudoTypesinterface is specifically designed to integrate with Storybook's addon system throughdefinePreviewAddon<PseudoTypes>(), providing type safety for thepseudoparameter that controls pseudo-state behavior like hover, focus, and other CSS pseudo-states.The refactoring consolidates all type definitions in
types.ts, updates imports inwithPseudoState.tsto use the centralized types, and modifiesindex.tsto export the new types while applying generic typing to the preview addon definition. This follows Storybook's modern addon patterns and improves the developer experience without changing any runtime behavior.PR Description Notes:
Confidence score: 5/5
Summary by CodeRabbit
New Features
Refactor
Tests
Chores