React: Add optional React type peers to packages that publish React-based declarations#34641
Merged
Merged
Conversation
Agent-Logs-Url: https://github.com/storybookjs/storybook/sessions/0404ed78-06b5-4a1d-9efa-d49a6bf76017 Co-authored-by: JReinhold <5678122+JReinhold@users.noreply.github.com>
Agent-Logs-Url: https://github.com/storybookjs/storybook/sessions/0404ed78-06b5-4a1d-9efa-d49a6bf76017 Co-authored-by: JReinhold <5678122+JReinhold@users.noreply.github.com>
Agent-Logs-Url: https://github.com/storybookjs/storybook/sessions/0404ed78-06b5-4a1d-9efa-d49a6bf76017 Co-authored-by: JReinhold <5678122+JReinhold@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix missing peer dependencies for React types
Add optional React type peers to packages that publish React-based declarations
Apr 27, 2026
JReinhold
approved these changes
Apr 27, 2026
Contributor
Contributor
|
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 ignored due to path filters (1)
📒 Files selected for processing (7)
📝 WalkthroughWalkthroughSeven packages across the monorepo add Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Comment |
Package BenchmarksCommit: The following packages have significant changes to their size or dependencies:
|
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 0 | 0 | 0 |
| Self size | 19 KB | 19 KB | 🚨 +266 B 🚨 |
| Dependency size | 791 B | 1 KB | 🚨 +312 B 🚨 |
| Bundle Size Analyzer | Link | Link |
ndelangen
approved these changes
Apr 28, 2026
This was referenced Apr 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #34640
What I did
Several published Storybook packages ship
.d.tsfiles that import fromreactand/orreact-dom, but did not declare the corresponding@types/*packages as accessible dependencies. This breaks stricter package resolvers such as pnpm's global virtual store, where those transitive type packages are no longer implicitly available.Details
Add optional React type peers
@types/reactas an optional peer dependency for packages whose published declarations reference React types:@storybook/addon-docs@storybook/addon-linksstorybook@storybook/nextjs@storybook/nextjs-vite@storybook/react@storybook/react-dom-shimAdd optional React DOM type peers where needed
@types/react-domas an optional peer dependency for packages whose published surface also depends on React DOM typings:@storybook/react@storybook/react-dom-shim@storybook/nextjs@storybook/nextjs-viteKeep non-React consumers unaffected
peerDependenciesMeta, so projects that do not use these React-typed surfaces are not forced to install them.Example of the manifest change pattern:
{ "peerDependencies": { "@types/react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", "@types/react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" }, "peerDependenciesMeta": { "@types/react": { "optional": true }, "@types/react-dom": { "optional": true } } }Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
Caution
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 publish.yml --field pr=<PR_NUMBER>Summary by CodeRabbit
@types/reactand@types/react-dom) are now declared as optional peer dependencies across packages, allowing consumers to omit installation without errors while maintaining type compatibility when present.