Repository navigation
Conversation
preview.meta() infers args from the props of a Svelte component, like the React and Vue renderers. definePreview adds the renderer's preview annotations itself, because CSF factories mode ignores preset previewAnnotations. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The SvelteKit definePreview adds the SvelteKit mocks and types parameters.sveltekit_experimental. The types now accept what the mocks accept at runtime: each nested mock is optional, callbacks may return anything, and page.error is SvelteKit's error object. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
⛔ Files ignored due to path filters (1)
📒 Files selected for processing (18)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. WalkthroughThe Svelte renderer adds typed preview and story factories. The Svelte Vite and SvelteKit frameworks expose preview APIs. SvelteKit adds typed experimental parameters and mock shapes. Tests cover factory typing and portable story composition. ChangesSvelte Preview and CSF
Sequence Diagram(s)sequenceDiagram
participant Consumer
participant SvelteKitDefinePreview
participant SvelteDefinePreview
Consumer->>SvelteKitDefinePreview: Project annotations and optional addons
SvelteKitDefinePreview->>SvelteDefinePreview: Pass annotations with SvelteKit addon prepended
SvelteDefinePreview-->>SvelteKitDefinePreview: Return typed Svelte preview
SvelteKitDefinePreview-->>Consumer: Return typed SvelteKit preview
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to No issue requiring a change before merge was identified; normal validation remains appropriate. ✨ Finishing Touches 💡 1📝 Generate docstrings
🛠️ Fix failing CI checks 💡
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. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
kasperpeulen
left a comment
There was a problem hiding this comment.
Looks good, nice work! One type issue inline that I'd fix before merging.
svelte-check types a runes component without `$props()` as `Component<Record<string, never>>`, so every arg had to be `never`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…support-csf4-factories-in-regular-csf-files
Closes #
What I did
Adds CSF4 factories to Svelte, for stories in
.stories.tsand.stories.jsfiles. Linear: SB-2211. Svelte CSF (.stories.svelte) builds on this in a later PR.Summary
preview.meta()infers args from the Svelte component props, with the same rules as React and Vue: args set in meta are optional in stories,preview.type<>(),meta.type<>()and decorators add args, and a component with unknown props (the*.svelteshim orany) takes any args.Choices to review:
parameters.sveltekit_experimentalis now typed, so I fixed the types to accept what the mocks accept. Before, CSF3 parameters were untyped, so nobody saw these errors. The documentedstate: { page }alone,enhance: () => {}and SvelteKit'spage.errorwere rejected. Now each nested mock object is partial, callbacks can return anything, andpage.erroris{ message: string }.as any:LoaderStoryComponenttakesloadedas optional, andInputFilledStoryComponenttypes its props asRecord<string, unknown>.Follow-ups, recorded on SB-2211 and not in this PR:
rendermust return a component whose props accept every story arg (SvelteRenderer['storyResult']is typed by args). Factories are a bit stricter here than CSF3.meta.story()accepts unknown args when the story also sets a required arg. The overload is the same in React and Vue, so the fix belongs in shared code.Evidence
renderers/svelte/src/csf-factories.test.tshas the Vue3 cases plus snippet props,$bindableprops, callback props, generic components and a component without props.svelte-checkpasses, and every@ts-expect-errorin it is used.portable-stories-factory.test.tsruns every factory story withStory.run()and snapshots the DOM.addonsand the mock parameter types.svelte-kit/skeleton-ts), with the preview switched todefinePreviewand two factory stories files:$app/state.svelte-checkreports a missing required arg and a wrongsveltekit_experimentaltype in the factory files.Merge Danger
Door: two-way. The change adds new exports and doesn't change existing ones.
Blast Radius: small. Existing CSF3 and Svelte CSF files keep working. The only change that existing users can see is the type of
SvelteKitParameters, which is now less strict than before.Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
Caution
This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!
Run a sandbox:
yarn task sandbox --start-from auto --template svelte-kit/skeleton-ts.In
.storybook/main.ts, setstoriesto["../src/factories/*.stories.ts"]and removepreviewAnnotations.Replace
.storybook/preview.tswith:Add
src/factories/Button.stories.ts:Run
yarn storybook. Check that both stories render a large primary button.Run
yarn vitest --run --project storybook. Both stories pass.Remove
labelfromPrimaryand runyarn check.svelte-checkreports thatlabelis missing.Documentation
MIGRATION.MD
The docs for Svelte factories come with the Svelte CSF support (SB-2215).
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 - 🚫 Not run
This PR does not have a canary release associated.
In-repo PRs: add the
ci:canarylabel. Later pushes republish while the label remains.🤖 Generated with Claude Code