Skip to content

Build: Upgrade type-fest to latest version 5.6.0#34791

Merged
valentinpalkovic merged 7 commits into
storybookjs:nextfrom
tobiasdiez:type-fest-upgrade
May 21, 2026
Merged

Build: Upgrade type-fest to latest version 5.6.0#34791
valentinpalkovic merged 7 commits into
storybookjs:nextfrom
tobiasdiez:type-fest-upgrade

Conversation

@tobiasdiez
Copy link
Copy Markdown
Contributor

@tobiasdiez tobiasdiez commented May 13, 2026

What I did

Update type-fest. Triggered by

[MISSING_EXPORT] "Jsonify" is not exported by "node_modules/.pnpm/type-fest@2.19.0/node_modules/type-fest/source/jsonify.d.ts".

when using rolldown (see tobiasdiez/storybook-vue-addon#238).

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Make 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/core team 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>

Summary by CodeRabbit

  • Chores

    • Upgraded type-fest to v5 across core and renderer packages, standardizing type utilities and inference.
    • Removed obsolete type-casting workarounds and suppression comments.
  • Bug Fixes / Improvements

    • Improved package manifest and script update behavior to perform in-place updates for more reliable writes.
    • CLI/type refinements adjust typings for multiple frameworks without changing runtime behavior.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 13, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Upgrade type-fest to v5.6.0 across manifests, migrate RemoveIndexSignature → OmitIndexSignature in multiple type-level inference sites, change package.json write logic to mutate fields in-place, and remove two obsolete type-workaround/comments.

Changes

type-fest v5.6.0 upgrade and type utility migration

Layer / File(s) Summary
Dependency version upgrades
code/core/package.json, code/renderers/react/package.json, code/renderers/svelte/package.json, code/renderers/vue3/package.json, package.json, scripts/package.json
type-fest updated to ^5.6.0 across core, renderer, and workspace root package manifests; root resolution key adjusted.
Type utility migration to OmitIndexSignature
code/core/src/csf/story.ts, code/frameworks/angular/src/client/preview.ts, code/frameworks/tanstack-react/src/index.ts, code/renderers/react/src/preview.tsx, code/renderers/vue3/src/preview.ts, code/renderers/vue3/src/public-types.ts, code/renderers/web-components/src/preview.ts
Replaced RemoveIndexSignature with OmitIndexSignature in args, decorator, and slot type inference used by CSF story types and multiple renderer/framework preview typings.
Manifest and package write behavior changes
code/core/src/cli/eslintPlugin.ts, code/core/src/common/js-package-manager/JsPackageManager.ts
Now mutate packageJson.eslintConfig / packageJson.scripts in-place and call writePackageJson(packageJson, ...) instead of constructing new object literals before writing.
Type workaround removals and minor codemod cleanup
code/core/src/cli/dev.ts, code/lib/cli-storybook/src/codemod/csf-factories.ts
Removed an as unknown as PackageJson cast in dev flow and deleted an obsolete // @ts-expect-error`` comment in the csf-factories codemod.

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Possibly related PRs:
    • storybookjs/storybook#33526: Both PRs touch Web Components renderer arg inference (code/renderers/web-components/src/preview.ts) and TypeScript typing for inferred args.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@tobiasdiez
Copy link
Copy Markdown
Contributor Author

I also noticed that type-fest and ts-dedent are actual dependencies for the svelte/vue renderes, but only dev deps for react. Is this on purpose or should I make them dev deps everywhere?

@tobiasdiez tobiasdiez added build Internal-facing build tooling & test updates ci:normal labels May 14, 2026
@tobiasdiez tobiasdiez force-pushed the type-fest-upgrade branch from c936ccf to ca00b5e Compare May 14, 2026 18:21
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@code/core/src/cli/eslintPlugin.ts`:
- Line 326: The call to packageManager.writePackageJson(packageJson) uses the
default cwd and can write the ESLint config to the wrong manifest in monorepos;
update the call so writePackageJson explicitly targets the primary package
directory you derived (use the primary package path or primaryPackageJson’s
directory) when persisting packageJson (i.e., invoke
packageManager.writePackageJson with the packageJson and the primary package
path/dir argument or API variant that accepts a target directory) to ensure the
config is written to primaryPackageJson’s package manifest.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d145d017-7d10-4b2c-9ba2-d41e620599cb

📥 Commits

Reviewing files that changed from the base of the PR and between c936ccf and ca00b5e.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (17)
  • code/core/package.json
  • code/core/src/cli/dev.ts
  • code/core/src/cli/eslintPlugin.ts
  • code/core/src/common/js-package-manager/JsPackageManager.ts
  • code/core/src/csf/story.ts
  • code/frameworks/angular/src/client/preview.ts
  • code/frameworks/tanstack-react/src/index.ts
  • code/lib/cli-storybook/src/codemod/csf-factories.ts
  • code/renderers/react/package.json
  • code/renderers/react/src/preview.tsx
  • code/renderers/svelte/package.json
  • code/renderers/vue3/package.json
  • code/renderers/vue3/src/preview.ts
  • code/renderers/vue3/src/public-types.ts
  • code/renderers/web-components/src/preview.ts
  • package.json
  • scripts/package.json
💤 Files with no reviewable changes (1)
  • code/lib/cli-storybook/src/codemod/csf-factories.ts
✅ Files skipped from review due to trivial changes (2)
  • package.json
  • scripts/package.json
🚧 Files skipped from review as they are similar to previous changes (11)
  • code/core/package.json
  • code/renderers/react/package.json
  • code/renderers/svelte/package.json
  • code/frameworks/tanstack-react/src/index.ts
  • code/renderers/vue3/package.json
  • code/renderers/react/src/preview.tsx
  • code/renderers/vue3/src/preview.ts
  • code/renderers/vue3/src/public-types.ts
  • code/core/src/cli/dev.ts
  • code/core/src/csf/story.ts
  • code/frameworks/angular/src/client/preview.ts

Comment thread code/core/src/cli/eslintPlugin.ts Outdated
@tobiasdiez tobiasdiez force-pushed the type-fest-upgrade branch from ca00b5e to 92dda65 Compare May 14, 2026 18:46
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@code/core/src/common/js-package-manager/JsPackageManager.ts`:
- Around line 613-617: The code mutates the shared cached packageJson object
in-place by assigning to packageJson.scripts before calling writePackageJson,
which can leave the in-memory cache inconsistent if the disk write fails; fix by
creating a shallow copy of packageJson (e.g., newPackageJson = { ...packageJson,
scripts: { ...packageJson.scripts, ...scripts } }) and pass that copy to
writePackageJson instead of mutating packageJson; ensure any cache update only
happens after a successful write (update the cached reference to newPackageJson
only once writePackageJson completes) while referring to the packageJson
variable, the scripts variable, and the writePackageJson method in
JsPackageManager.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e2db3171-ec86-4302-b2b2-38c9b542db60

📥 Commits

Reviewing files that changed from the base of the PR and between ca00b5e and 92dda65.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (17)
  • code/core/package.json
  • code/core/src/cli/dev.ts
  • code/core/src/cli/eslintPlugin.ts
  • code/core/src/common/js-package-manager/JsPackageManager.ts
  • code/core/src/csf/story.ts
  • code/frameworks/angular/src/client/preview.ts
  • code/frameworks/tanstack-react/src/index.ts
  • code/lib/cli-storybook/src/codemod/csf-factories.ts
  • code/renderers/react/package.json
  • code/renderers/react/src/preview.tsx
  • code/renderers/svelte/package.json
  • code/renderers/vue3/package.json
  • code/renderers/vue3/src/preview.ts
  • code/renderers/vue3/src/public-types.ts
  • code/renderers/web-components/src/preview.ts
  • package.json
  • scripts/package.json
💤 Files with no reviewable changes (1)
  • code/lib/cli-storybook/src/codemod/csf-factories.ts
✅ Files skipped from review due to trivial changes (3)
  • scripts/package.json
  • package.json
  • code/renderers/vue3/src/public-types.ts
🚧 Files skipped from review as they are similar to previous changes (11)
  • code/core/src/cli/dev.ts
  • code/renderers/svelte/package.json
  • code/renderers/web-components/src/preview.ts
  • code/core/package.json
  • code/renderers/react/package.json
  • code/frameworks/angular/src/client/preview.ts
  • code/core/src/csf/story.ts
  • code/renderers/react/src/preview.tsx
  • code/renderers/vue3/src/preview.ts
  • code/core/src/cli/eslintPlugin.ts
  • code/frameworks/tanstack-react/src/index.ts

Comment on lines +613 to +617
packageJson.scripts = {
...packageJson.scripts,
...scripts,
};
this.writePackageJson(packageJson, operationDir);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Avoid mutating cached packageJson before disk write succeeds.

On Line 613, packageJson is mutated in-place (shared cache object) before writePackageJson. If the write throws, cache state can diverge from disk state.

Suggested fix
   public addScripts(scripts: Record<string, string>) {
     const { operationDir, packageJson } = this.#getPrimaryPackageJson();

-    packageJson.scripts = {
-      ...packageJson.scripts,
-      ...scripts,
-    };
-    this.writePackageJson(packageJson, operationDir);
+    const nextPackageJson = {
+      ...packageJson,
+      scripts: {
+        ...packageJson.scripts,
+        ...scripts,
+      },
+    };
+    this.writePackageJson(nextPackageJson, operationDir);
   }
🤖 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/common/js-package-manager/JsPackageManager.ts` around lines 613
- 617, The code mutates the shared cached packageJson object in-place by
assigning to packageJson.scripts before calling writePackageJson, which can
leave the in-memory cache inconsistent if the disk write fails; fix by creating
a shallow copy of packageJson (e.g., newPackageJson = { ...packageJson, scripts:
{ ...packageJson.scripts, ...scripts } }) and pass that copy to writePackageJson
instead of mutating packageJson; ensure any cache update only happens after a
successful write (update the cached reference to newPackageJson only once
writePackageJson completes) while referring to the packageJson variable, the
scripts variable, and the writePackageJson method in JsPackageManager.

@storybook-app-bot
Copy link
Copy Markdown

storybook-app-bot Bot commented May 14, 2026

Package Benchmarks

Commit: b9641ae, ran on 21 May 2026 at 14:05:32 UTC

The following packages have significant changes to their size or dependencies:

storybook

Before After Difference
Dependency count 72 72 0
Self size 20.25 MB 20.27 MB 🚨 +19 KB 🚨
Dependency size 36.17 MB 36.17 MB 0 B
Bundle Size Analyzer Link Link

@storybook/angular

Before After Difference
Dependency count 185 185 0
Self size 142 KB 160 KB 🚨 +17 KB 🚨
Dependency size 30.73 MB 30.73 MB 🎉 -54 B 🎉
Bundle Size Analyzer Link Link

@storybook/nextjs

Before After Difference
Dependency count 534 534 0
Self size 662 KB 662 KB 0 B
Dependency size 61.37 MB 61.41 MB 🚨 +34 KB 🚨
Bundle Size Analyzer Link Link

@storybook/nextjs-vite

Before After Difference
Dependency count 93 93 0
Self size 1.38 MB 1.38 MB 🎉 -48 B 🎉
Dependency size 24.79 MB 24.83 MB 🚨 +34 KB 🚨
Bundle Size Analyzer Link Link

@storybook/preact-vite

Before After Difference
Dependency count 14 14 0
Self size 13 KB 13 KB 🎉 -12 B 🎉
Dependency size 1.47 MB 1.49 MB 🚨 +23 KB 🚨
Bundle Size Analyzer Link Link

@storybook/react-native-web-vite

Before After Difference
Dependency count 122 122 0
Self size 30 KB 30 KB 0 B
Dependency size 25.86 MB 25.90 MB 🚨 +34 KB 🚨
Bundle Size Analyzer Link Link

@storybook/react-vite

Before After Difference
Dependency count 83 83 0
Self size 36 KB 36 KB 🚨 +18 B 🚨
Dependency size 22.57 MB 22.60 MB 🚨 +34 KB 🚨
Bundle Size Analyzer Link Link

@storybook/react-webpack5

Before After Difference
Dependency count 271 271 0
Self size 23 KB 23 KB 🚨 +12 B 🚨
Dependency size 45.91 MB 45.94 MB 🚨 +34 KB 🚨
Bundle Size Analyzer Link Link

@storybook/svelte-vite

Before After Difference
Dependency count 19 20 🚨 +1 🚨
Self size 56 KB 56 KB 🎉 -12 B 🎉
Dependency size 26.65 MB 27.00 MB 🚨 +352 KB 🚨
Bundle Size Analyzer Link Link

@storybook/sveltekit

Before After Difference
Dependency count 20 21 🚨 +1 🚨
Self size 56 KB 56 KB 0 B
Dependency size 26.71 MB 27.06 MB 🚨 +352 KB 🚨
Bundle Size Analyzer Link Link

@storybook/tanstack-react

Before After Difference
Dependency count 84 84 0
Self size 107 KB 106 KB 🎉 -1 KB 🎉
Dependency size 22.60 MB 22.64 MB 🚨 +34 KB 🚨
Bundle Size Analyzer Link Link

@storybook/vue3-vite

Before After Difference
Dependency count 108 109 🚨 +1 🚨
Self size 36 KB 36 KB 0 B
Dependency size 43.75 MB 44.10 MB 🚨 +352 KB 🚨
Bundle Size Analyzer Link Link

@storybook/web-components-vite

Before After Difference
Dependency count 15 15 0
Self size 19 KB 19 KB 🚨 +12 B 🚨
Dependency size 1.52 MB 1.54 MB 🚨 +17 KB 🚨
Bundle Size Analyzer Link Link

@storybook/cli

Before After Difference
Dependency count 203 203 0
Self size 908 KB 908 KB 🎉 -55 B 🎉
Dependency size 87.56 MB 87.58 MB 🚨 +19 KB 🚨
Bundle Size Analyzer Link Link

@storybook/codemod

Before After Difference
Dependency count 196 196 0
Self size 32 KB 32 KB 🚨 +36 B 🚨
Dependency size 86.05 MB 86.06 MB 🚨 +19 KB 🚨
Bundle Size Analyzer Link Link

create-storybook

Before After Difference
Dependency count 73 73 0
Self size 1.08 MB 1.08 MB 🎉 -66 B 🎉
Dependency size 56.43 MB 56.45 MB 🚨 +19 KB 🚨
Bundle Size Analyzer node node

@storybook/preact

Before After Difference
Dependency count 2 2 0
Self size 23 KB 46 KB 🚨 +23 KB 🚨
Dependency size 32 KB 32 KB 0 B
Bundle Size Analyzer Link Link

@storybook/react

Before After Difference
Dependency count 59 59 0
Self size 1.47 MB 1.51 MB 🚨 +34 KB 🚨
Dependency size 13.30 MB 13.30 MB 0 B
Bundle Size Analyzer Link Link

@storybook/svelte

Before After Difference
Dependency count 2 3 🚨 +1 🚨
Self size 49 KB 49 KB 🚨 +1 B 🚨
Dependency size 230 KB 582 KB 🚨 +352 KB 🚨
Bundle Size Analyzer Link Link

@storybook/vue3

Before After Difference
Dependency count 3 4 🚨 +1 🚨
Self size 66 KB 66 KB 🚨 +7 B 🚨
Dependency size 213 KB 565 KB 🚨 +352 KB 🚨
Bundle Size Analyzer Link Link

@storybook/web-components

Before After Difference
Dependency count 3 3 0
Self size 62 KB 79 KB 🚨 +17 KB 🚨
Dependency size 47 KB 47 KB 0 B
Bundle Size Analyzer Link Link

@tobiasdiez
Copy link
Copy Markdown
Contributor Author

I cannot reproduce the failing ts failures locally. :(

@huang-julien
Copy link
Copy Markdown
Contributor

I also noticed that type-fest and ts-dedent are actual dependencies for the svelte/vue renderes, but only dev deps for react. Is this on purpose or should I make them dev deps everywhere?

It seems to be used in react public API files though. It probably needs to be moved as dependency in react instead.

valentinpalkovic and others added 3 commits May 21, 2026 13:50
The root `resolutions` field forced every package in the tree onto a
single type-fest version. Raising it to v5 broke external packages
whose typings target older type-fest majors (e.g. react-joyride, whose
types rely on type-fest v2-era utilities).

Drop the global `type-fest` resolution so each package resolves the
version it declares, and scope react-joyride to type-fest v2 — the
version it was effectively pinned to before this upgrade.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`writePackageJson` defaults to `cwd`; pass the primary package's
`operationDir` so the storybook ESLint config is written to the
correct manifest in monorepos.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@valentinpalkovic valentinpalkovic changed the title Build: upgrade type-fest to latest version 5.6.0 Build: Upgrade type-fest to latest version 5.6.0 May 21, 2026
@valentinpalkovic valentinpalkovic removed the build Internal-facing build tooling & test updates label May 21, 2026
@valentinpalkovic
Copy link
Copy Markdown
Contributor

Picked this up to get it merge-ready. Summary of what I changed on top of the original type-fest bump:

  • Merged latest next and resolved the code/renderers/vue3/package.json conflict (kept type-fest@^5.6.0 + next's vue-component-type-helpers@^3.2.9).
  • Dropped the global type-fest entry from root resolutions. It was forcing every package in the tree (not just Storybook's) onto a single type-fest version. Raising it to v5 broke external packages whose typings target older type-fest majors — most visibly react-joyride, which broke TourGuide/onboarding type-checks. Removing the global override lets each package resolve the version it declares; vue3 and svelte checks recovered for free.
  • Scoped react-joyride to type-fest@~2.19 via resolutions. react-joyride@^4.27.0's declared type-fest is not type-compatible with how Storybook consumes its Step types; ~2.19 is the version it was effectively pinned to before this PR, so this preserves existing behavior.
  • Addressed the CodeRabbit review note in eslintPlugin.ts (write to the primary package's operationDir). The other note (addScripts in-place mutation) was left as-is — the suggested non-mutating spread does not type-check against type-fest v5's stricter PackageJson, which is exactly why the original PR switched to in-place mutation.

yarn nx run-many -t check is fully green locally (the lone nextjs-vite:check failure reproduces identically on a clean next checkout — pre-existing, unrelated to this PR).

Reflect the type-fest resolution change in the ecosystem-ci
`EXISTING_RESOLUTIONS` set so it stays in sync with the root
package.json `resolutions` keys.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@valentinpalkovic valentinpalkovic self-assigned this May 21, 2026
@valentinpalkovic valentinpalkovic moved this from Empathy Queue (prioritized) to In Progress in Core Team Projects May 21, 2026
@valentinpalkovic valentinpalkovic merged commit 5544e37 into storybookjs:next May 21, 2026
128 of 129 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Core Team Projects May 21, 2026
@valentinpalkovic valentinpalkovic added the patch:yes Bugfix & documentation PR that need to be picked to main branch label May 21, 2026
@github-actions github-actions Bot mentioned this pull request May 21, 2026
14 tasks
@tobiasdiez tobiasdiez deleted the type-fest-upgrade branch May 21, 2026 18:59
@tobiasdiez
Copy link
Copy Markdown
Contributor Author

Thanks @valentinpalkovic!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-scan:mixed ci:normal core dependencies patch:yes Bugfix & documentation PR that need to be picked to main branch

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants