Skip to content

Dependencies: Upgrade TypeScript to 6.0.3#34971

Open
valentinpalkovic wants to merge 4 commits into
nextfrom
valentin/upgrade-typescript-6
Open

Dependencies: Upgrade TypeScript to 6.0.3#34971
valentinpalkovic wants to merge 4 commits into
nextfrom
valentin/upgrade-typescript-6

Conversation

@valentinpalkovic
Copy link
Copy Markdown
Contributor

@valentinpalkovic valentinpalkovic commented May 29, 2026

What I did

Upgrades the repository to TypeScript 6.0.3 (latest).

  • Bumped typescript ^5.9.3^6.0.3 across the workspace (all devDependencies plus the root resolutions pin that forces a single TS version). Published frameworks' peer/runtime ranges (@storybook/angular, @storybook/svelte-vite, @storybook/vue3-vite) were widened (… || ^6.0.0) rather than hard-pinned, so downstream TypeScript 5 consumers keep working.
  • Bumped the supporting toolchain to versions that support TS 6.0: @typescript-eslint/* 8.488.60, svelte-check 4.34.4.8, svelte2tsx 0.7.440.7.55.
  • Fixed the handful of type-check changes TS 6.0 introduced:
    • base code/tsconfig.jsonnoUncheckedSideEffectImports: false (Storybook intentionally relies on bundler-resolved import './x.css' side-effect imports, which tsc can't resolve) and ignoreDeprecations: "5.0""6.0" (silences the new baseUrl deprecation, which also broke vue-tsc).
    • core — declared the deep ESM entrypoints of react-syntax-highlighter (@types/react-syntax-highlighter doesn't cover them) and removed two now-redundant @ts-expect-error directives.
    • react renderer — access the optional jest global via globalThis (its ambient value is no longer in scope under 6.0).
    • nextjs-vite — typed the ./vite-plugin export at its source and dropped the declare module augmentation that now conflicts with TS 6.0's self-referencing module resolution.

Verification (all green locally)

Check Result
yarn nx run-many -t check — 43 projects, incl. vue-tsc + svelte-check ✅ 0 type errors
yarn nx run-many -t compile — all packages
yarn lint — full repo (typescript-eslint 8.60 + eslint-plugin-storybook) ✅ 0 errors
react renderer unit tests ✅ 98 passed
eslint-plugin unit tests (rule-tester) ✅ 161 passed

Out of scope (follow-up)

TypeScript 6.0 is incompatible with the Angular toolchain currently pinned here: @angular/compiler-cli only permits TS 6.0 from ≥ 21.2, and this repo is on 19.1. @storybook/angular's own source type-checks fine under TS 6.0, but compiling Angular sandboxes (ng build) will hit Angular's hard MAX_TS_VERSION guard until Angular is bumped two majors (19 → 21). That upgrade is intentionally deferred — it overlaps in-flight angular-vite work. test-storybooks/* fixtures were also left on their pinned TS versions (standalone test repos, not part of the workspace type-check).

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

In addition to unit tests, the primary signal for a TypeScript upgrade is the repo's own check (full-monorepo tsc) and lint CI — both pass.

Manual testing

This is a toolchain/dependency upgrade with no runtime behavior change — TypeScript types are erased by the esbuild-based build, so the produced JS is unchanged. It is exercised entirely by CI (check, lint, unit tests), all green locally. To verify manually:

  1. yarn && yarn nx run-many -t check → 0 type errors across all 43 projects.
  2. cd code && yarn lint → 0 errors.
  3. yarn task --task sandbox --start-from auto --template react-vite/default-ts and confirm Storybook starts/renders.

Note: Angular sandboxes are expected to fail to compile under TS 6.0 (see "Out of scope" above) — a deferred follow-up, not a regression in this PR.

Documentation

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

No user-facing API changes; no docs/migration update required.

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: dependencies (applied)

    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 publish.yml --field pr=<PR_NUMBER>

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Upgraded TypeScript to 6.0 across packages, frameworks, and developer tooling.
    • Updated TypeScript configuration to handle deprecations and side-effect imports for smoother builds.
    • Adjusted type annotations and added targeted type-check suppressions to maintain compatibility with third‑party tooling and runtime behavior.

Review Change Stack

Bump TypeScript ^5.9.3 -> ^6.0.3 across the workspace (devDependencies +
root resolutions). Published frameworks' peer/runtime ranges are widened
(... || ^6.0.0) so TypeScript 5 consumers keep working.

Supporting toolchain bumps for TS 6.0 compatibility:
- @typescript-eslint/* 8.48 -> 8.60
- svelte-check 4.3 -> 4.4.8, svelte2tsx 0.7.44 -> 0.7.55

Fixes for TS 6.0 type-check changes:
- base tsconfig: noUncheckedSideEffectImports:false (bundler-resolved CSS
  side-effect imports), ignoreDeprecations "5.0" -> "6.0" (baseUrl)
- core: declare deep ESM entrypoints of react-syntax-highlighter
- react: access optional jest global via globalThis
- nextjs-vite: type the vite-plugin export at source, drop the now-conflicting
  module augmentation

Angular sandbox runtime is intentionally out of scope: TS 6.0 requires
@angular/compiler-cli >= 21.2 (repo is on 19.1); tracked as a follow-up.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@valentinpalkovic valentinpalkovic added dependencies ci:normal Run our default set of CI jobs (choose this for most PRs). labels May 29, 2026
@valentinpalkovic valentinpalkovic self-assigned this May 29, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 29, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 518a12ab-7c35-461f-aeba-aeb7c726ae5f

📥 Commits

Reviewing files that changed from the base of the PR and between 43312b4 and 1da9e0d.

📒 Files selected for processing (2)
  • code/frameworks/svelte-vite/package.json
  • code/frameworks/vue3-vite/package.json

📝 Walkthrough

Walkthrough

This pull request upgrades Storybook's TypeScript version to 6.0 across the monorepo, updates TS config for 6.0 deprecations and side-effect imports, suppresses untyped deep ESM imports from react-syntax-highlighter, refactors Jest global access in the React renderer, restructures Next.js Vite plugin typing, and reformats package-manager method signatures.

Changes

TypeScript 6.0 Upgrade

Layer / File(s) Summary
TypeScript 6.0 dependency upgrade across monorepo
code/addons/*/package.json, code/builders/*/package.json, code/frameworks/*/package.json, code/lib/*/package.json, code/presets/*/package.json, code/renderers/*/package.json, scripts/package.json, code/package.json, package.json
TypeScript bumped from ^5.8/5.9.x to ^6.0.3 across many workspace packages; some @typescript-eslint ranges were updated and root resolutions adjusted.
TypeScript configuration updates for 6.0
code/tsconfig.json, code/frameworks/angular/package.json, code/frameworks/svelte-vite/package.json, code/frameworks/vue3-vite/package.json, package.json
ignoreDeprecations set to "6.0" and noUncheckedSideEffectImports set to false in tsconfig; Angular peerDependencies expanded and svelte-related dependency bump applied.
React-syntax-highlighter type suppression and d.ts exclusion
code/core/src/components/components/syntaxhighlighter/syntaxhighlighter.tsx, code/core/src/components/components/syntaxhighlighter/syntaxhighlighter.stories.tsx, scripts/build/utils/entry-utils.ts
Add // @ts-expect-error`` before untyped deep ESM imports; mark react-syntax-highlighter as excluded from d.ts bundling with comments about missing types and TS 6 behavior.
Jest globals refactoring for type safety
code/renderers/react/src/entry-preview.tsx
Access Jest via globalThis.jest with optional chaining and use a typed globalThis cast when checking fake timers to avoid unscoped jest assumptions.
Next.js Vite plugin type declaration restructure
code/frameworks/nextjs-vite/src/index.ts, code/frameworks/nextjs-vite/src/vite-plugin/index.ts
Remove module augmentation and add an explicit typeof annotation for the exported storybookNextJsPlugin while keeping the runtime require.
Package manager proxy method signature formatting
code/core/src/common/js-package-manager/BUNProxy.ts, code/core/src/common/js-package-manager/NPMProxy.ts, code/core/src/common/js-package-manager/PNPMProxy.ts
Reformat getResolutions signatures to multi-line parameter layout and add explicit return type annotations; no behavioral changes.

🎯 2 (Simple) | ⏱️ ~12 minutes


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

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/frameworks/angular/package.json`:
- Line 86: The package.json peerDependencies currently advertises "typescript"
^6.0.3 which incorrectly allows TS 6.x; update the peerDependencies.typescript
entry in package.json to restrict TypeScript to the range compatible with
Angular 19.1 (for example ">=5.5.0 <5.8.0") so it no longer includes 6.x; locate
the peerDependencies block and change the typescript constraint accordingly
(ensure consistency with any references to `@angular/compiler-cli` or Angular 19.1
compatibility notes).
🪄 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: 54246d86-9aab-411e-a7cc-b8c8ab860b58

📥 Commits

Reviewing files that changed from the base of the PR and between 3c67edf and 2020522.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (48)
  • code/addons/a11y/package.json
  • code/addons/docs/package.json
  • code/addons/links/package.json
  • code/addons/onboarding/package.json
  • code/addons/pseudo-states/package.json
  • code/addons/themes/package.json
  • code/addons/vitest/package.json
  • code/builders/builder-webpack5/package.json
  • code/core/package.json
  • code/core/src/components/components/syntaxhighlighter/syntaxhighlighter.tsx
  • code/core/src/typings.d.ts
  • code/frameworks/angular/package.json
  • code/frameworks/ember/package.json
  • code/frameworks/html-vite/package.json
  • code/frameworks/nextjs-vite/package.json
  • code/frameworks/nextjs-vite/src/index.ts
  • code/frameworks/nextjs-vite/src/vite-plugin/index.ts
  • code/frameworks/nextjs/package.json
  • code/frameworks/preact-vite/package.json
  • code/frameworks/react-native-web-vite/package.json
  • code/frameworks/react-vite/package.json
  • code/frameworks/server-webpack5/package.json
  • code/frameworks/svelte-vite/package.json
  • code/frameworks/sveltekit/package.json
  • code/frameworks/tanstack-react/package.json
  • code/frameworks/vue3-vite/package.json
  • code/frameworks/web-components-vite/package.json
  • code/lib/cli-storybook/package.json
  • code/lib/codemod/package.json
  • code/lib/core-webpack/package.json
  • code/lib/create-storybook/package.json
  • code/lib/csf-plugin/package.json
  • code/lib/eslint-plugin/package.json
  • code/lib/react-dom-shim/package.json
  • code/package.json
  • code/presets/create-react-app/package.json
  • code/presets/react-webpack/package.json
  • code/presets/server-webpack/package.json
  • code/renderers/html/package.json
  • code/renderers/preact/package.json
  • code/renderers/react/src/entry-preview.tsx
  • code/renderers/server/package.json
  • code/renderers/svelte/package.json
  • code/renderers/vue3/package.json
  • code/renderers/web-components/package.json
  • code/tsconfig.json
  • package.json
  • scripts/package.json
💤 Files with no reviewable changes (2)
  • code/core/src/components/components/syntaxhighlighter/syntaxhighlighter.tsx
  • code/frameworks/nextjs-vite/src/index.ts

"empathic": "^2.0.0",
"rimraf": "^6.0.1",
"typescript": "^5.9.3",
"typescript": "^6.0.3",
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 | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

For @angular/compiler-cli 19.1.x, what TypeScript versions are officially supported? Is TypeScript ^6.0.0 supported?

💡 Result:

For @angular/compiler-cli version 19.1.x, the officially supported TypeScript versions are >=5.5.0 and <5.8.0 [1][2]. TypeScript ^6.0.0 is not supported by Angular 19.1.x [1][2]. Support for TypeScript 6.0.0 was introduced in later versions of the Angular framework [3].

Citations:


Fix Angular 19.1 peerDependencies to avoid advertising unsupported TypeScript 6
Line 104 widens peerDependencies.typescript to include ^6.0.0, but Angular 19.1.x (@angular/compiler-cli) officially supports TypeScript >=5.5.0 and <5.8.0; TS 6.x is not supported. Keep the peer capped to TS 5.x (e.g., <5.8.0) until the Angular toolchain supports TypeScript 6.

🤖 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/frameworks/angular/package.json` at line 86, The package.json
peerDependencies currently advertises "typescript" ^6.0.3 which incorrectly
allows TS 6.x; update the peerDependencies.typescript entry in package.json to
restrict TypeScript to the range compatible with Angular 19.1 (for example
">=5.5.0 <5.8.0") so it no longer includes 6.x; locate the peerDependencies
block and change the typescript constraint accordingly (ensure consistency with
any references to `@angular/compiler-cli` or Angular 19.1 compatibility notes).

valentinpalkovic and others added 2 commits May 29, 2026 12:06
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The production build (compile:production) surfaced issues the noEmit type-check
did not:

- js-package-manager proxies (NPM/PNPM/BUN): annotate getResolutions with the
  abstract contract's `Record<string, any>` return type, so declaration emit no
  longer leaks the un-nameable `PackageJson.DependencyOverrides` namespace type
  (TS4053) once rollup-plugin-dts renames the bundled PackageJson type.

- react-syntax-highlighter: TS 6.0 no longer falls back to
  @types/react-syntax-highlighter for the deep ESM entrypoints, so:
  - suppress the now-untyped imports with @ts-expect-error (type-check), and
  - mark react-syntax-highlighter as types-external so rollup-plugin-dts stops
    walking its CJS source (which fails on refractor/core and exhausts the heap).
    It stays bundled in the JS output, like ast-types.

Verified: nx check (43 projects) and nx compile -c production (42 projects) both green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@storybook-app-bot
Copy link
Copy Markdown

storybook-app-bot Bot commented May 29, 2026

Package Benchmarks

Commit: 1da9e0d, ran on 29 May 2026 at 14:10:26 UTC

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

storybook

Before After Difference
Dependency count 72 72 0
Self size 20.39 MB 20.38 MB 🎉 -16 KB 🎉
Dependency size 36.11 MB 36.11 MB 0 B
Bundle Size Analyzer Link Link

@storybook/cli

Before After Difference
Dependency count 203 203 0
Self size 908 KB 908 KB 🚨 +144 B 🚨
Dependency size 88.58 MB 88.57 MB 🎉 -16 KB 🎉
Bundle Size Analyzer Link Link

@storybook/codemod

Before After Difference
Dependency count 196 196 0
Self size 32 KB 32 KB 0 B
Dependency size 87.07 MB 87.05 MB 🎉 -16 KB 🎉
Bundle Size Analyzer Link Link

create-storybook

Before After Difference
Dependency count 73 73 0
Self size 1.08 MB 1.08 MB 0 B
Dependency size 56.50 MB 56.49 MB 🎉 -16 KB 🎉
Bundle Size Analyzer node node

….0.0

svelte-vite and vue3-vite ship `typescript` as a runtime dependency (for docgen).
Widening the range to include ^6.0.0 made Yarn resolve typescript@6.0.3 (highest in
range) when these packages are portaled into the TS-5 test-storybooks, conflicting
with their typescript@5.9.x at link time (YN0071) and failing the portable-stories
CI jobs.

The monorepo build is unaffected — the root `resolutions` pin forces typescript@6.0.3
regardless of the declared range — so revert these two ranges to their previous values
to keep the published contract identical and let TS-5 consumers dedupe as before.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@valentinpalkovic valentinpalkovic added ci:daily Run the CI jobs that normally run in the daily job. and removed ci:normal Run our default set of CI jobs (choose this for most PRs). labels May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:daily Run the CI jobs that normally run in the daily job. dependencies

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant