React: Preserve @ts-expect-error in preview#32442
Merged
Merged
Conversation
|
View your CI Pipeline Execution ↗ for commit 22d82d2
☁️ Nx Cloud last updated this comment at |
8 tasks
Contributor
|
@ndelangen please make a canary release for this PR to test it out. |
Contributor
Author
|
@ndelangen thanks, canary works great - patch no longer required to support |
ndelangen
approved these changes
Sep 16, 2025
This was referenced Sep 16, 2025
Contributor
|
@ndelangen @vanessayuenn - Hello 👋 - Can this change the patched on Storybook 9? We had the issue there and we are not ready to test Storybook 10. |
Package BenchmarksCommit: The following packages have significant changes to their size or dependencies:
|
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 18 | 18 | 0 |
| Self size | 2.06 MB | 2.01 MB | 🎉 -50 KB 🎉 |
| Dependency size | 9.43 MB | 9.43 MB | 🚨 +6 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/builder-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 11 | 11 | 0 |
| Self size | 319 KB | 374 KB | 🚨 +55 KB 🚨 |
| Dependency size | 1.30 MB | 1.30 MB | 🎉 -18 B 🎉 |
| Bundle Size Analyzer | Link | Link |
storybook
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 48 | 48 | 0 |
| Self size | 30.11 MB | 30.42 MB | 🚨 +302 KB 🚨 |
| Dependency size | 17.64 MB | 17.65 MB | 🚨 +6 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/html-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 14 | 14 | 0 |
| Self size | 23 KB | 23 KB | 🚨 +18 B 🚨 |
| Dependency size | 1.66 MB | 1.71 MB | 🚨 +55 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/nextjs
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 529 | 529 | 0 |
| Self size | 939 KB | 928 KB | 🎉 -12 KB 🎉 |
| Dependency size | 58.64 MB | 58.63 MB | 🎉 -6 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/nextjs-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 124 | 130 | 🚨 +6 🚨 |
| Self size | 4.01 MB | 4.00 MB | 🎉 -12 KB 🎉 |
| Dependency size | 21.58 MB | 21.66 MB | 🚨 +79 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/preact-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 14 | 14 | 0 |
| Self size | 14 KB | 14 KB | 🎉 -18 B 🎉 |
| Dependency size | 1.64 MB | 1.70 MB | 🚨 +55 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/react-native-web-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 157 | 163 | 🚨 +6 🚨 |
| Self size | 31 KB | 31 KB | 🚨 +24 B 🚨 |
| Dependency size | 22.97 MB | 23.05 MB | 🚨 +79 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/react-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 114 | 120 | 🚨 +6 🚨 |
| Self size | 36 KB | 36 KB | 🚨 +1 B 🚨 |
| Dependency size | 19.52 MB | 19.60 MB | 🚨 +79 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/svelte-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 22 | 22 | 0 |
| Self size | 59 KB | 59 KB | 🎉 -18 B 🎉 |
| Dependency size | 26.89 MB | 26.95 MB | 🚨 +55 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/sveltekit
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 23 | 23 | 0 |
| Self size | 49 KB | 49 KB | 🚨 +60 B 🚨 |
| Dependency size | 26.95 MB | 27.01 MB | 🚨 +55 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/vue3-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 109 | 110 | 🚨 +1 🚨 |
| Self size | 38 KB | 38 KB | 🚨 +77 B 🚨 |
| Dependency size | 43.76 MB | 43.82 MB | 🚨 +63 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/web-components-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 15 | 15 | 0 |
| Self size | 20 KB | 20 KB | 0 B |
| Dependency size | 1.68 MB | 1.74 MB | 🚨 +55 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/cli
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 192 | 205 | 🚨 +13 🚨 |
| Self size | 886 KB | 886 KB | 🎉 -462 B 🎉 |
| Dependency size | 80.05 MB | 81.72 MB | 🚨 +1.67 MB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/codemod
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 174 | 174 | 0 |
| Self size | 35 KB | 35 KB | 🎉 -42 B 🎉 |
| Dependency size | 76.48 MB | 76.79 MB | 🚨 +308 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
create-storybook
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 49 | 49 | 0 |
| Self size | 1.55 MB | 1.52 MB | 🎉 -24 KB 🎉 |
| Dependency size | 47.76 MB | 48.06 MB | 🚨 +308 KB 🚨 |
| Bundle Size Analyzer | node | node |
@storybook/preset-react-webpack
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 170 | 170 | 0 |
| Self size | 21 KB | 26 KB | 🚨 +6 KB 🚨 |
| Dependency size | 30.84 MB | 30.84 MB | 🚨 +6 B 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/react
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 2 | 2 | 0 |
| Self size | 884 KB | 872 KB | 🎉 -12 KB 🎉 |
| Dependency size | 18 KB | 18 KB | 0 B |
| Bundle Size Analyzer | Link | Link |
Merged
5 tasks
ndelangen
added a commit
that referenced
this pull request
Sep 18, 2025
React: Preserve `@ts-expect-error` in preview (cherry picked from commit f968cc9)
8 tasks
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.
What I did
Switched the
@ts-expect-errorcomments from inline//to docstring/** */. The former typescript discards, the latter it preserves.This ensures that those with
skipLibCheck: falsedo not get errors.I did spend considerable time trying to work out why there was an error but got stuck in a complete typing quagmire. It seems that the arg types are passed around in three separate places - as
Renderer['T'],Renderer['args']and also as a secondTArgstype argument to many methods.Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
The react sandbox should now be type checkable with skipLibCheck: false
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 pull request has been released as version
0.0.0-pr-32442-sha-22d82d2d. Try it out in a new sandbox by runningnpx storybook@0.0.0-pr-32442-sha-22d82d2d sandboxor in an existing project withnpx storybook@0.0.0-pr-32442-sha-22d82d2d upgrade.More information
0.0.0-pr-32442-sha-22d82d2dpreserve-expect-error22d82d2d1757944109)To request a new release of this pull request, mention the
@storybookjs/coreteam.core team members can create a new canary release here or locally with
gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=32442Greptile Summary
Updated On: 2025-09-11 15:59:12 UTC
This PR addresses a TypeScript compilation issue in the React renderer by converting three
@ts-expect-errorcomments from inline (//) format to JSDoc (/** */) format. The change is made incode/renderers/react/src/preview.tsxat lines 51, 84, and 108.The core issue stems from TypeScript's behavior when compiling code: inline comments are discarded during compilation, while JSDoc comments are preserved. This creates problems for users who have
skipLibCheck: falsein their TypeScript configuration, as they encounter type errors that should be suppressed.The affected locations contain complex interface definitions involving the React renderer's type system, where there are intricate relationships between
Renderer['T'],Renderer['args'], andTArgstype parameters. These create unavoidable type conflicts that require error suppression. Rather than attempting to resolve the underlying type complexity (which the author describes as a "typing quagmire"), this pragmatic solution ensures the error suppressions persist through compilation.This change integrates well with Storybook's broader architecture by maintaining the existing type safety mechanisms while ensuring compatibility with stricter TypeScript configurations. The modification is minimal and surgical, preserving all existing functionality while solving the compilation issue.
Confidence score: 5/5