Skip to content

Typescript: Exclude all dunderscore prefixed folders from production compilation - #36740

Merged
valentinpalkovic merged 2 commits into
nextfrom
bill/fix-leaky-react
Oct 16, 2026
Merged

valentinpalkovic merged 2 commits into
nextfrom
bill/fix-leaky-react

Conversation

@mrginglymus

@mrginglymus mrginglymus commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Closes #35663

What I did

Production builds first transpile code to plain .d.ts files. There is an exclusion filter on this process to exclude test files, but it did not capture the file contianing this line:

import type { StorybookConfig } from '@storybook/react-webpack5';

This transiently imports @storybook/react which reexports Args from storybook/internal/types. If this was found first(?) typescript would deem it the canonical import source and reference it in all usages.

I updated the exclusion glob to exclude any dunderscore prefixed directory.

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

  1. Run a canary
  2. check storybook code contains no type references to @storybook/react.

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

  • Declare whether manual QA will be needed for this PR during the next release, through qa:needed or qa:skip

  • 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 - 🚢 Released 8dbf69e

This pull request has been released as canary packages. Try it out in a new project or update an existing project with the commands below.

# For a new project
npx --yes --allow-remote=all https://pkg.pr.new/create-storybook@8dbf69e

# or for an existing project
npx --yes --allow-remote=all https://pkg.pr.new/storybook@8dbf69e upgrade

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor
Fails
🚫

PR is not labeled with one of: ["qa:needed","qa:skip","qa:success"]

Generated by 🚫 dangerJS against 8dbf69e

@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b7fc67ec-562f-4a9c-a97b-952bafd7d07f
📥 Commits

Reviewing files that changed from the base of the PR and between 16f00d6 and 8dbf69e.

📒 Files selected for processing: 1
  • scripts/build/utils/generate-types-rolldown.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Walkthrough

The declaration generator now uses the __*/ pattern to exclude directories whose names begin with double underscores.

Changes

Declaration type exclusions

Layer / File(s) Summary
Broaden directory exclusions
scripts/build/utils/generate-types-rolldown.ts
DTS_EXCLUDES replaces separate exclusions for __tests__, __mocks__, and __testfixtures__ with the __*/ pattern.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 8dbf6

The broadened exclusion covers nested double-underscore directories in production declaration generation. No merge-blocking issue was identified.

✨ Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@Sidnioulz Sidnioulz added the ci:canary Trigger canary releases for this PR label Oct 12, 2026
@mrginglymus

mrginglymus commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor Author

It works!

If there's a chance this could be backported to 10 that would be phenomenal.

@storybook-contribution-review storybook-contribution-review Bot added bug review:1-architecture In automated review pipeline: awaiting stage 1 architecture review sev:S2 High priority. Fix within weeks. typescript labels Oct 13, 2026

@storybook-contribution-review storybook-contribution-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 I am the Storybook contribution review bot; a human maintainer approved this message before it was posted.
Review phase: Runtime verification (stage 3 of 3)

We are trying a three-stage automated review: architecture, code quality, and runtime verification. This message states which stages ran and which were skipped. A human maintainer approves each public message and makes the final decision. Please tell us whether the feedback and evidence are useful.

Hi @mrginglymus, thanks for tracing this leak back to the __for-testing__ fixture. That was a tricky one to find! All three review stages passed on commit 16f00d6: architecture, code quality and runtime verification. No stage was skipped.

Runtime verification. We ran a local production build of the storybook package (scripts/build/build-package.ts --prod, default rolldown-tsgo dts path) at the base commit 271a436 and at this PR's head:

  • Base: dist/**/*.d.ts contains 165 import("@storybook/react") type references (162 × Args, 3 × Parameters), for example in the enhanceArgTypes signature. This is the leak from #35663, and a second clean build gave the same count.
  • Head: the same build emits 0 of them. Those types now resolve through storybook/internal/types and storybook/internal/csf.
  • No production types dropped: the d.ts file list (61 files), the set of emitted source modules (717) and the exported names of every entry file are identical at base and head. Every other changed line is one of these type-reference rewrites.

Architecture and code quality. Every __* directory under code/ holds only tests, mocks or fixtures, and a tsconfig exclude only drops files that no production module imports. So **/__*/** follows the repo convention and cannot remove a type that is in use. It is also simpler than keeping a list of directory names up to date.

One optional suggestion: a short comment on that line, for example // __tests__, __mocks__, __testfixtures__, …: test-only by convention, would record the convention the exclude now depends on. This is not required.

Scope of this check: we verified only the storybook package, which is the one named in #35663. We did not type-check the emitted d.ts in a consumer project. A maintainer makes the final decision on merging this PR and on your request for a 10.x backport.

@storybook-contribution-review storybook-contribution-review Bot added review:verified Three-step review passed: architecture, code quality, runtime verification and removed review:1-architecture In automated review pipeline: awaiting stage 1 architecture review labels Oct 13, 2026
@valentinpalkovic valentinpalkovic added the ci:normal Run our default set of CI jobs (choose this for most PRs). label Oct 13, 2026
@valentinpalkovic valentinpalkovic self-assigned this Oct 13, 2026
@storybook-app-bot

storybook-app-bot Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Package Benchmarks

Commit: 8dbf69e, ran on 15 October 2026 at 13:19:45 UTC

No significant changes detected, all good. 👏

@valentinpalkovic valentinpalkovic removed their assignment Oct 15, 2026
@valentinpalkovic valentinpalkovic moved this to Ready for work in Core Team Projects Oct 15, 2026
@valentinpalkovic
valentinpalkovic merged commit 029657f into next Oct 16, 2026
144 of 146 checks passed
@valentinpalkovic
valentinpalkovic deleted the bill/fix-leaky-react branch October 16, 2026 09:00
@github-project-automation github-project-automation Bot moved this from Ready for work to Done in Core Team Projects Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug ci:canary Trigger canary releases for this PR ci:normal Run our default set of CI jobs (choose this for most PRs). review:verified Three-step review passed: architecture, code quality, runtime verification sev:S2 High priority. Fix within weeks. typescript

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Bug]: Incorrect types when storybook built on linux - works on windows

3 participants