Repository navigation
Conversation
The enabled variant of `StorybookConfig['refs']` was typed as
`{ title: string; url: string }`, so the documented `sourceUrl` (used by the
sidebar's ref indicator to link to the source code) and `expanded` (documented
as optional and true by default) were rejected in a typed `main.ts`, although
both are honoured at runtime. Add both optional fields and a type test that
compiles the documented example.
Closes storybookjs#32239
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. WalkthroughChangesRefs type support
Fixed issue severity: Medium Merge Risk: ⚪ Minimal · up to This localized change expands the enabled refs type to match documented and already-supported fields, with a type-level regression test; no actionable merge-blocking risk remains beyond normal checks and review. ✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
Comment |
There was a problem hiding this comment.
🤖 I am the Storybook contribution review bot. This message was posted automatically; a human maintainer makes the final decision.
Review phase: Final verdict: Architecture review (stage 1 of 3), Thermo-nuclear code quality review (stage 2 of 3) and Runtime verification (stage 3 of 3) completedWe are trying a three-stage automated review: architecture, code quality, and runtime verification. This message states which stages ran and which were skipped. Messages are posted automatically, and a human maintainer makes the final decision. Please tell us whether the feedback and evidence are useful.
Thanks @theRizwan, this is a clean, well-scoped fix for #32239. All three review stages passed on d8405c85:
- Architecture:
CoreCommon_StorybookRefsis the single type behindStorybookConfig['refs'], so the fix reaches every consumer. It now matches whatgetRefsalready passes through at runtime and what therefsdocs describe. Adding optional members is not a breaking change. - Code quality: the change is minimal, and the new type test fails against the base type and passes on this branch.
- Runtime verification: a
main.ts-style config typedStorybookConfigwithsourceUrlandexpandedfails type checking on the base (TS2353: 'sourceUrl' does not exist in type …) and passes on this branch. The function form ofrefs,disable: true, and rejection of asourceURLtypo behave as before. Not run: a rendered composition check in the manager UI, because the diff only changes types.
I left two optional suggestions inline on the test. They are not needed for merge, and the bot will not review them again. One more optional note without an inline location, because the file is not in this diff: the function-form signature in docs/api/main-config/main-config-refs.mdx shows sourceUrl as required, while the type makes it optional. That predates this PR and could be a small docs follow-up.
There was a problem hiding this comment.
🤖 I am the Storybook contribution review bot. This message was posted automatically; a human maintainer makes the final decision.
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. Messages are posted automatically, and a human maintainer makes the final decision. Please tell us whether the feedback and evidence are useful.
The merge of next in c6283d6 left this PR's own change as it was, so the earlier architecture and code quality passes still apply and were not re-run. Since then, next has started type-checking *.test-d.ts files with Vitest, and tests--linux now fails on this head because of the new type test. I've moved the PR from review:verified to review:changes-requested for this one item, which is described inline. When it's fixed, I'll re-check only this item.
| @@ -0,0 +1,20 @@ | |||
| import { expectTypeOf } from 'vitest'; | |||
There was a problem hiding this comment.
Blocking: tests--linux fails on c6283d6 with Error: No test suite found in file …/core-common.test-d.ts (CircleCI job 2334363). next now runs *.test-d.ts files through Vitest typecheck, and Vitest requires every test file to contain at least one test or describe. If this merges as it is, tests--linux fails on next.
Please wrap the assertions in a test(...) block, as the other *.test-d.ts files do (for example code/core/src/backgrounds/index.test-d.ts):
import { expectTypeOf, test } from 'vitest';
import type { StorybookConfigRaw } from './core-common.ts';
type Refs = NonNullable<StorybookConfigRaw['refs']>;
test('accepts the documented refs shape', () => {
// The documented shape of `refs`: https://storybook.js.org/docs/api/main-config/main-config-refs
const refs = {
// ...unchanged...
} satisfies Refs;
expectTypeOf(refs).toExtend<Refs>();
});
Hi @theRizwan, thanks again for this contribution! Our review on 2026-10-19 asked for some changes, and this PR has had no new activity since 2026-10-19. If you are still working on it, push your changes or reply here: any new commit or reply keeps the PR open. Without new activity, this PR will be closed automatically on or after 2026-11-02. A maintainer can reopen it later if you come back to it. |
Vitest now typechecks *.test-d.ts files and needs a test or describe in each. Also add a negative case so the new optional members cannot loosen the excess-property check.
There was a problem hiding this comment.
🤖 I am the Storybook contribution review bot. This message was posted automatically; a human maintainer makes the final decision.
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. Messages are posted automatically, and a human maintainer makes the final decision. Please tell us whether the feedback and evidence are useful.
Thanks @theRizwan, the update in 7be2db9 fixes the item from our last review. Vitest now finds core-common.test-d.ts as a test suite, and both tests pass with no type errors in the core typecheck project (run locally, because CI has not run on this head). The @ts-expect-error test fails as expected when the key is changed to the valid sourceUrl, so it guards against the typo for the right reason.
We re-ran the original check on this head: a StorybookConfig with a ref that sets sourceUrl and expanded fails on the base with TS2353 and type-checks on this PR. The function form of refs, disable: true, and the rejection of unknown keys work as before.
Stages: only runtime verification (stage 3) re-ran for this follow-up. The architecture and code quality passes from the first round still apply, because this update changes only the type test file. Not run: the full CI tests--linux job and rendering in the manager UI (the change is types only).
All three stages have now passed, and the PR is marked review:verified. A maintainer decides on the merge.
Closes #32239
What I did
The enabled variant of the
refsentry ofStorybookConfigwas typed as{ title: string; url: string }. It is missing two fields that the documentation lists and that the manager honours at runtime:sourceUrl, which the sidebar's ref indicator uses to render the "View source code" link for a composed Storybook (code/core/src/manager/components/sidebar/RefIndicator.tsx:171);expanded, documented as "Optional, true by default" on an enabled ref, but which only existed on the disabled variant.So the exact example on https://storybook.js.org/docs/api/main-config/main-config-refs fails to typecheck in a typed
main.ts, even though both values work. This adds the two optional fields to the enabled variant. The disabled variant is untouched, so no existing config stops compiling.A new
core-common.test-d.tscompiles the documented example againstStorybookConfigRaw['refs'], so the type cannot drift from the docs again without failing the core project's vitest typecheck. I confirmed it fails onnexttoday withObject literal may only specify known properties, and 'sourceUrl' does not exist in type ....Claude Code assisted with the investigation and the patch, as CONTRIBUTING.md asks contributors to disclose. I reviewed and tested every change.
Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
code/core/src/types/modules/core-common.test-d.tsis a type level test, run by the core project's vitest typecheck:Manual testing
refsexample from the refs docs page into.storybook/main.ts, keepingexpanded: falseandsourceUrl.tsc --noEmiton the project, or open the file in an editor. Before this changesourceUrlandexpandedare reported as unknown properties on the enabled ref. With it, the file typechecks.sourceUrl, exactly as before, since only the type changed.Documentation
MIGRATION.MD
No documentation change. The docs already describe this shape, the type now matches them.
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.tsDeclare whether manual QA will be needed for this PR during the next release, through
qa:neededorqa:skipMake 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>