Skip to content

Conversation

@xeho91
Copy link
Contributor

@xeho91 xeho91 commented May 6, 2025

What I did

  • Clean up types inside the /code/renderers/svelte:

    • remove ancient code (unused and from 2019)
    • drop usage of legacy types (for Svelte 4 components - when it was a class), and simplify by using modern Component
  • update tests for /code/renderers/svelte/public-types.ts

  • removed dependency expect-type which is bundled into Vitest

  • replace deprecated toMatchTypeOf with toExtend in tests

  • remove type tests related to Events (Svelte 5 components no longer needs those types, because they were related to
    legacy on:<event-name> directive)

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

  • Refactor
    • Unified Svelte public typings to a single Component/ComponentProps model and simplified generics; several components' prop declarations were converted from exported props to internal destructured props, which may affect TypeScript consumers.
  • Tests
    • Simplified and updated type tests and story typings, removed legacy Svelte4/5 scenarios, and adjusted assertions/imports; some sample test components were removed or updated.
  • Chores
    • Removed an unused dev dependency.

@nx-cloud
Copy link

nx-cloud bot commented May 6, 2025

View your CI Pipeline Execution ↗ for commit 49291b2

Command Status Duration Result
nx run-many -t build --parallel=3 ✅ Succeeded 50s View ↗

☁️ Nx Cloud last updated this comment at 2025-09-26 13:19:32 UTC

Copy link
Contributor

@JReinhold JReinhold left a comment

Choose a reason for hiding this comment

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

LGTM! 🎉

Will need @kasperpeulen's eyes as well.

If possible would also love @dummdidumm's eyes on this, to ensure we haven't missed anything. The relevant context is that we've dropped support for Svelte 4 now.

@JReinhold JReinhold self-assigned this May 19, 2025
@JReinhold JReinhold added maintenance User-facing maintenance tasks svelte labels May 19, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR simplifies and modernizes the Svelte renderer types by removing legacy code and types while updating tests to reflect the new modern component API. Key changes include replacing legacy Svelte component types with the modern Component interface, updating associated generic types, and revising unit tests to use the new type assertion method.

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
code/renderers/svelte/src/types.ts Simplified types by removing legacy Svelte types and updating the SvelteRenderer interface.
code/renderers/svelte/src/public-types.ts Updated public types to use modern Component type and adjusted type inference in Meta and StoryObj.
code/renderers/svelte/src/public-types.test.ts Revised tests to align with updated type definitions and replaced deprecated assertions.
code/renderers/svelte/src/test/Decorator*.svelte Updated decorator test components to use $props() and new render syntax.
code/renderers/svelte/src/test/Button.svelte Updated Button component to align with Svelte 5 event binding and API changes.
code/renderers/svelte/package.json Removed the now redundant dependency "expect-type".

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 24, 2025

Walkthrough

The changes migrate Svelte typings and test components to a unified Component/ComponentProps model. Multiple test Svelte components stop using exported export let props and instead destructure typed props from $props() (including replacing <slot /> with typed children + {@render children()}), and ButtonV5.svelte was removed. Public type definitions (public-types.ts, types.ts, public-types.test.ts, typings.d.ts) replace Svelte 4/5 union types (SvelteComponent / Svelte5ComponentType) with a single Component/ComponentProps approach and update SvelteRenderer, StoryFn, StoryObj, SvelteStoryResult, and related signatures. The devDependency expect-type was removed and some test imports trimmed.

Sequence Diagram(s)

mermaid
sequenceDiagram
autonumber
participant Parent as Parent Component / Story
participant OldComp as Svelte Component (old)
participant NewComp as Svelte Component (new)

Note over Parent,OldComp: Old prop flow
Parent->>OldComp: set exported props (export let ...)
OldComp-->>Parent: uses exported props in template

Note over Parent,NewComp: New prop flow
Parent->>NewComp: pass props object
NewComp->>NewComp: $props() destructure into typed locals
NewComp-->>Parent: uses local typed vars in template

mermaid
sequenceDiagram
autonumber
participant Consumer as Story/Meta author
participant OldTypes as Public types (pre-change)
participant NewTypes as Public types (post-change)

Note over Consumer,OldTypes: Old typing model
Consumer->>OldTypes: provide SvelteComponent or Svelte5Component
OldTypes-->>Consumer: StoryObj/Meta typed with SvelteComponent|Svelte5ComponentType

Note over Consumer,NewTypes: New typing model
Consumer->>NewTypes: provide Component (typeof Component)
NewTypes-->>Consumer: StoryObj/Meta typed with Component / ComponentProps

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title accurately captures the central refactoring of Svelte renderer types by emphasizing the simplification of public types through adoption of the modern Component type and is clear, concise, and directly related to the main changeset.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

@storybook-app-bot
Copy link

storybook-app-bot bot commented Sep 24, 2025

Package Benchmarks

Commit: 49291b2, ran on 26 September 2025 at 13:10:00 UTC

No significant changes detected, all good. 👏

@JReinhold JReinhold marked this pull request as ready for review September 26, 2025 11:22
Copy link
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: 2

🧹 Nitpick comments (2)
code/renderers/svelte/src/types.ts (2)

11-23: Prefer component: C for stronger specificity and inference

You already parameterize SvelteRenderer as <C extends Component...>. Typing component as C tightens the contract and avoids coupling it to this['T'] (which represents args, not necessarily the component’s props).

-export interface SvelteRenderer<C extends Component<any, any, any> = Component<any, any, any>>
+export interface SvelteRenderer<C extends Component<any, any, any> = Component<any, any, any>>
   extends WebRenderer {
-  component: Component<this['T'] extends Record<string, any> ? this['T'] : any>;
+  component: C;

18-22: Optional: make props optional in mount options

Several Storybook render paths call mount() without props. Consider making props optional to ease adoption while keeping type-safety when provided.

-  options?: Record<string, any> & { props: ComponentProps<C> }
+  options?: Record<string, any> & { props?: ComponentProps<C> }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 756b758 and 3eadd2c.

⛔ Files ignored due to path filters (1)
  • code/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (14)
  • code/renderers/svelte/package.json (0 hunks)
  • code/renderers/svelte/src/__test__/Button.svelte (1 hunks)
  • code/renderers/svelte/src/__test__/ButtonV5.svelte (0 hunks)
  • code/renderers/svelte/src/__test__/Decorator.svelte (1 hunks)
  • code/renderers/svelte/src/__test__/Decorator2.svelte (1 hunks)
  • code/renderers/svelte/src/__test__/composeStories/Button.stories.ts (1 hunks)
  • code/renderers/svelte/src/__test__/composeStories/CustomRenderComponent.svelte (1 hunks)
  • code/renderers/svelte/src/__test__/composeStories/LoaderStoryComponent.svelte (1 hunks)
  • code/renderers/svelte/src/__test__/composeStories/StoryWithLocaleComponent.svelte (1 hunks)
  • code/renderers/svelte/src/__test__/composeStories/portable-stories.test.ts (1 hunks)
  • code/renderers/svelte/src/public-types.test.ts (9 hunks)
  • code/renderers/svelte/src/public-types.ts (3 hunks)
  • code/renderers/svelte/src/types.ts (1 hunks)
  • code/renderers/svelte/src/typings.d.ts (1 hunks)
💤 Files with no reviewable changes (2)
  • code/renderers/svelte/package.json
  • code/renderers/svelte/src/test/ButtonV5.svelte
🧰 Additional context used
📓 Path-based instructions (4)
code/**/*.{test,spec}.{ts,tsx}

📄 CodeRabbit inference engine (.cursorrules)

code/**/*.{test,spec}.{ts,tsx}: Place all test files under the code/ directory
Name test files as *.test.ts, *.test.tsx, *.spec.ts, or *.spec.tsx

Files:

  • code/renderers/svelte/src/__test__/composeStories/portable-stories.test.ts
  • code/renderers/svelte/src/public-types.test.ts
**/*.test.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/spy-mocking.mdc)

**/*.test.{ts,tsx,js,jsx}: Use vi.mock() with the spy: true option for all package and file mocks in Vitest tests
Place all mocks at the top of the test file before any test cases
Use vi.mocked() to type and access mocked functions
Implement mock behaviors in beforeEach blocks
Mock all required dependencies that the test subject uses
Mock implementations should be placed in beforeEach blocks
Each mock implementation should return a Promise for async functions
Mock implementations should match the expected return type of the original function
Use vi.mocked() to access and implement mock behaviors
Mock all required properties and methods that the test subject uses
Avoid direct function mocking without vi.mocked()
Avoid mock implementations outside of beforeEach blocks
Avoid mocking without the spy: true option
Avoid inline mock implementations within test cases
Avoid mocking only a subset of required dependencies
Mock at the highest level of abstraction needed
Keep mock implementations simple and focused
Use type-safe mocking with vi.mocked()
Document complex mock behaviors
Group related mocks together

Files:

  • code/renderers/svelte/src/__test__/composeStories/portable-stories.test.ts
  • code/renderers/svelte/src/public-types.test.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Adhere to ESLint and Prettier rules across all JS/TS source files

Files:

  • code/renderers/svelte/src/__test__/composeStories/portable-stories.test.ts
  • code/renderers/svelte/src/__test__/composeStories/Button.stories.ts
  • code/renderers/svelte/src/types.ts
  • code/renderers/svelte/src/typings.d.ts
  • code/renderers/svelte/src/public-types.test.ts
  • code/renderers/svelte/src/public-types.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Fix type errors and prefer precise typings instead of using any or suppressions, consistent with strict mode

Files:

  • code/renderers/svelte/src/__test__/composeStories/portable-stories.test.ts
  • code/renderers/svelte/src/__test__/composeStories/Button.stories.ts
  • code/renderers/svelte/src/types.ts
  • code/renderers/svelte/src/typings.d.ts
  • code/renderers/svelte/src/public-types.test.ts
  • code/renderers/svelte/src/public-types.ts
🧠 Learnings (11)
📚 Learning: 2025-09-17T08:11:47.196Z
Learnt from: CR
PR: storybookjs/storybook#0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-09-17T08:11:47.196Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Use vi.mock() with the spy: true option for all package and file mocks in Vitest tests

Applied to files:

  • code/renderers/svelte/src/__test__/composeStories/portable-stories.test.ts
📚 Learning: 2025-09-18T20:51:06.618Z
Learnt from: Sidnioulz
PR: storybookjs/storybook#32458
File: code/core/src/viewport/components/Tool.tsx:38-39
Timestamp: 2025-09-18T20:51:06.618Z
Learning: The useGlobals hook from storybook/manager-api returns a tuple where the third element (storyGlobals) is typed as Globals, not Globals | undefined. This means TypeScript guarantees it's always defined, making the `in` operator safe to use without additional null checks.

Applied to files:

  • code/renderers/svelte/src/__test__/composeStories/Button.stories.ts
📚 Learning: 2025-09-17T08:11:47.197Z
Learnt from: CR
PR: storybookjs/storybook#0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-09-17T08:11:47.197Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Document complex mock behaviors

Applied to files:

  • code/renderers/svelte/src/__test__/composeStories/LoaderStoryComponent.svelte
  • code/renderers/svelte/src/public-types.test.ts
📚 Learning: 2025-09-17T08:11:47.196Z
Learnt from: CR
PR: storybookjs/storybook#0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-09-17T08:11:47.196Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Mock all required properties and methods that the test subject uses

Applied to files:

  • code/renderers/svelte/src/__test__/composeStories/LoaderStoryComponent.svelte
📚 Learning: 2025-09-17T08:11:47.196Z
Learnt from: CR
PR: storybookjs/storybook#0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-09-17T08:11:47.196Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Use vi.mocked() to access and implement mock behaviors

Applied to files:

  • code/renderers/svelte/src/__test__/composeStories/LoaderStoryComponent.svelte
📚 Learning: 2025-09-17T08:11:47.196Z
Learnt from: CR
PR: storybookjs/storybook#0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-09-17T08:11:47.196Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Each mock implementation should return a Promise for async functions

Applied to files:

  • code/renderers/svelte/src/__test__/composeStories/LoaderStoryComponent.svelte
📚 Learning: 2025-09-17T08:11:47.196Z
Learnt from: CR
PR: storybookjs/storybook#0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-09-17T08:11:47.196Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Mock implementations should match the expected return type of the original function

Applied to files:

  • code/renderers/svelte/src/__test__/composeStories/LoaderStoryComponent.svelte
  • code/renderers/svelte/src/public-types.test.ts
📚 Learning: 2025-09-17T08:11:47.196Z
Learnt from: CR
PR: storybookjs/storybook#0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-09-17T08:11:47.196Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Use vi.mocked() to type and access mocked functions

Applied to files:

  • code/renderers/svelte/src/__test__/composeStories/LoaderStoryComponent.svelte
📚 Learning: 2025-09-17T08:11:47.196Z
Learnt from: CR
PR: storybookjs/storybook#0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-09-17T08:11:47.196Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Avoid direct function mocking without vi.mocked()

Applied to files:

  • code/renderers/svelte/src/__test__/composeStories/LoaderStoryComponent.svelte
📚 Learning: 2025-09-17T08:11:47.196Z
Learnt from: CR
PR: storybookjs/storybook#0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-09-17T08:11:47.196Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Avoid inline mock implementations within test cases

Applied to files:

  • code/renderers/svelte/src/__test__/composeStories/LoaderStoryComponent.svelte
📚 Learning: 2025-09-17T08:11:47.196Z
Learnt from: CR
PR: storybookjs/storybook#0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-09-17T08:11:47.196Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Mock implementations should be placed in beforeEach blocks

Applied to files:

  • code/renderers/svelte/src/__test__/composeStories/LoaderStoryComponent.svelte
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: normal
  • GitHub Check: Core Unit Tests, windows-latest
🔇 Additional comments (19)
code/renderers/svelte/src/__test__/composeStories/Button.stories.ts (1)

107-107: Type annotation improved for modern Svelte 5 component typing.

This correctly changes from StoryObj<CustomRenderComponent> to StoryObj<typeof CustomRenderComponent>, aligning with the modern Svelte 5 Component-based typing approach where component types are inferred using typeof rather than instance types.

code/renderers/svelte/src/__test__/Decorator2.svelte (2)

2-8: Modern Svelte 5 prop handling pattern correctly implemented.

This migration from exported props to typed internal props using $props() is consistent with Svelte 5's modern component patterns. The Props interface provides clear typing, and the destructuring assignment ensures type safety while maintaining the component's expected behavior.


13-13: Snippet rendering correctly replaces slot-based content.

The change from <slot /> to {@render children()} properly utilizes Svelte 5's Snippet pattern for composable content, which is the modern approach for passing renderable content between components.

code/renderers/svelte/src/__test__/composeStories/StoryWithLocaleComponent.svelte (2)

1-10: Props migration follows modern Svelte 5 patterns.

The transition from exported props to internal typed destructuring via $props() is correctly implemented. This approach provides better type safety and aligns with Svelte 5's component architecture where props are internally managed rather than exported.


15-15: Template syntax correctly updated for shorthand prop binding.

The change from <Button label={label} /> to <Button {label} /> uses Svelte's shorthand property binding syntax, which is cleaner and more idiomatic when the prop name matches the variable name.

code/renderers/svelte/src/__test__/Button.svelte (2)

2-10: Component modernization with proper TypeScript typing.

The refactor correctly implements the Svelte 5 pattern by:

  • Moving from exported props to a typed Props interface
  • Using $props() for internal prop management
  • Adding proper TypeScript types including an optional callback for the clicked prop
  • The comment accurately explains the dual typing approach needed for Svelte 5 function vs class components

13-13: Event handling correctly modernized from dispatch to direct callback.

Replacing the dispatch-based event pattern with direct onclick={clicked} binding is the appropriate modern Svelte 5 approach. This simplifies the event flow and improves type safety by making the callback explicit in the props interface.

code/renderers/svelte/src/__test__/composeStories/LoaderStoryComponent.svelte (2)

1-8: Props modernization with proper typing.

The migration from exported props to typed destructuring via $props() is implemented correctly. The inline type annotation provides clear contracts for both the mockFn function signature and loaded object structure.


10-10: Reactive data computation correctly updated with $derived.

Using $derived(mockFn && loaded && mockFn('render')) is the appropriate Svelte 5 pattern for computed values that depend on props. This replaces the previous reactive statement approach and provides better performance and clearer dependencies.

code/renderers/svelte/src/__test__/composeStories/portable-stories.test.ts (1)

4-4: Clean up unused Vitest import.

Removing the unused vi import is appropriate since the test doesn't use any mocking functionality. The remaining imports (afterEach, describe, expect, it) are sufficient for the test's requirements.

Based on coding guidelines, note that while this file has a .test.ts extension, the removal of vi import appears intentional since no mocking is used in this particular test file.

code/renderers/svelte/src/typings.d.ts (1)

5-8: Module typing correctly updated for Svelte 5 Component type.

This change properly migrates from the deprecated ComponentType to the modern Component type, which is the standard approach in Svelte 5. In Svelte 4, the common type is ComponentType, but in Svelte 5 it is Component. ComponentType is now obsolete because the new Component type is the component type already.

code/renderers/svelte/src/__test__/Decorator.svelte (2)

2-8: Modern component prop pattern correctly implemented.

The migration follows the same modernization pattern seen across other test components:

  • Importing Snippet type for renderable content
  • Defining a Props interface with proper typing
  • Using $props() destructuring for internal prop management

This approach provides better type safety and aligns with Svelte 5's component architecture.


13-13: Snippet rendering pattern correctly applied.

The replacement of <slot /> with {@render children()} properly implements Svelte 5's Snippet-based content composition, which is more explicit and type-safe than the previous slot-based approach.

code/renderers/svelte/src/public-types.test.ts (2)

2-2: LGTM: Switch to Vitest’s typed assertions

Importing expectTypeOf from vitest and using toExtend aligns with current best practices.


20-24: LGTM: Helper type aligns with new SvelteRenderer<Comp> shape

SvelteStory correctly threads the component through SvelteRenderer<Comp>.

code/renderers/svelte/src/public-types.ts (3)

27-31: LGTM: Meta simplified to modern Component

Clean conditional on Component<infer Props> removes legacy unions and keeps props inference accurate.


37-41: LGTM: StoryFn conditional matches new component typing

Using AnnotatedStoryFn<SvelteRenderer, Props> keeps the function shape consistent with the renderer.


47-65: LGTM: StoryObj inference over component and args

Correctly infers args via ComponentProps<Comp> and ArgsFromMeta, and threads SvelteRenderer<Comp>.

code/renderers/svelte/src/types.ts (1)

25-33: LGTM: SvelteStoryResult updated to Component-based surface

Using Component<Props, Exports, Bindings> for both Component and decorator aligns with Svelte 5 patterns.

…Component.svelte

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
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: 0

🧹 Nitpick comments (1)
code/renderers/svelte/src/public-types.test.ts (1)

20-24: Avoid shadowing imported Args; also remove unnecessary anys.

Rename generic params and constrain Comp to Component without arity to reduce noise and shadowing.

Apply this diff:

-type SvelteStory<Comp extends Component<any, any, any>, Args, RequiredArgs> = StoryAnnotations<
-  SvelteRenderer<Comp>,
-  Args,
-  RequiredArgs
->;
+type SvelteStory<Comp extends Component, TArgs, TRequiredArgs> = StoryAnnotations<
+  SvelteRenderer<Comp>,
+  TArgs,
+  TRequiredArgs
+>;
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 480f8b0 and 49291b2.

⛔ Files ignored due to path filters (1)
  • code/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (1)
  • code/renderers/svelte/src/public-types.test.ts (9 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
code/**/*.{test,spec}.{ts,tsx}

📄 CodeRabbit inference engine (.cursorrules)

code/**/*.{test,spec}.{ts,tsx}: Place all test files under the code/ directory
Name test files as *.test.ts, *.test.tsx, *.spec.ts, or *.spec.tsx

Files:

  • code/renderers/svelte/src/public-types.test.ts
**/*.test.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/spy-mocking.mdc)

**/*.test.{ts,tsx,js,jsx}: Use vi.mock() with the spy: true option for all package and file mocks in Vitest tests
Place all mocks at the top of the test file before any test cases
Use vi.mocked() to type and access mocked functions
Implement mock behaviors in beforeEach blocks
Mock all required dependencies that the test subject uses
Mock implementations should be placed in beforeEach blocks
Each mock implementation should return a Promise for async functions
Mock implementations should match the expected return type of the original function
Use vi.mocked() to access and implement mock behaviors
Mock all required properties and methods that the test subject uses
Avoid direct function mocking without vi.mocked()
Avoid mock implementations outside of beforeEach blocks
Avoid mocking without the spy: true option
Avoid inline mock implementations within test cases
Avoid mocking only a subset of required dependencies
Mock at the highest level of abstraction needed
Keep mock implementations simple and focused
Use type-safe mocking with vi.mocked()
Document complex mock behaviors
Group related mocks together

Files:

  • code/renderers/svelte/src/public-types.test.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Adhere to ESLint and Prettier rules across all JS/TS source files

Files:

  • code/renderers/svelte/src/public-types.test.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Fix type errors and prefer precise typings instead of using any or suppressions, consistent with strict mode

Files:

  • code/renderers/svelte/src/public-types.test.ts
🧠 Learnings (2)
📚 Learning: 2025-09-17T08:11:47.197Z
Learnt from: CR
PR: storybookjs/storybook#0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-09-17T08:11:47.197Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Document complex mock behaviors

Applied to files:

  • code/renderers/svelte/src/public-types.test.ts
📚 Learning: 2025-09-17T08:11:47.196Z
Learnt from: CR
PR: storybookjs/storybook#0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-09-17T08:11:47.196Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Mock implementations should match the expected return type of the original function

Applied to files:

  • code/renderers/svelte/src/public-types.test.ts
🧬 Code graph analysis (1)
code/renderers/svelte/src/public-types.test.ts (1)
code/core/src/csf/csf-factories.ts (1)
  • Meta (77-96)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: normal
  • GitHub Check: Core Unit Tests, windows-latest
🔇 Additional comments (13)
code/renderers/svelte/src/public-types.test.ts (13)

12-12: Modern Svelte typings import is correct.

Component/ComponentProps from svelte aligns with the new unified types.


28-38: Meta and explicit SvelteRenderer checks are correct.

The typeof usage in type positions and the toExtend assertions align with the new API.


47-49: Using default SvelteRenderer generic here is fine.

This keeps the test focused on props-as-generic for Meta.


55-67: satisfies + Meta + SvelteStory expectation reads correctly.

Type inference and RequiredArgs shape look right.


71-94: Combined meta/story args constraints are asserted correctly.

The negative case and subsequent Expected type are accurate.


103-108: Props-based Meta variant expectation is consistent.

Matches the required full-args shape.


112-118: StoryObj extends SvelteStory<typeof Button,…> is correct.

Confirms component-as-generic usage is valid.


126-145: Render-widened args inference looks good.

ComponentProps with additional theme discriminant resolves as expected.


156-172: Decorator-widened args inference is correct.

Decorator param surfaces in RequiredArgs as intended.


175-201: Multiple decorators inference validated.

Both decorator args are required and reflected properly.


205-212: Resolved: use typeof Button in type positions.

The previous issue is fixed; StoryObj and the final assertion are now correct.


215-224: Args-only StoryObj variants compile as intended.

Confirms overloaded generic usage.


2-2: Remove leftover expect-type imports and toMatchTypeOf usages across test files, replacing them with Vitest’s built-in expectTypeOf assertions.

⛔ Skipped due to learnings
Learnt from: CR
PR: storybookjs/storybook#0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-09-17T08:11:47.196Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Mock implementations should match the expected return type of the original function
Learnt from: CR
PR: storybookjs/storybook#0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-09-17T08:11:47.196Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Avoid inline mock implementations within test cases
Learnt from: CR
PR: storybookjs/storybook#0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-09-17T08:11:47.197Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Document complex mock behaviors
Learnt from: CR
PR: storybookjs/storybook#0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-09-17T08:11:47.196Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Avoid mock implementations outside of beforeEach blocks
Learnt from: CR
PR: storybookjs/storybook#0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-09-17T08:11:47.196Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Implement mock behaviors in beforeEach blocks
Learnt from: CR
PR: storybookjs/storybook#0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-09-17T08:11:47.197Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Keep mock implementations simple and focused
Learnt from: CR
PR: storybookjs/storybook#0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-09-17T08:11:47.197Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Use type-safe mocking with vi.mocked()
Learnt from: CR
PR: storybookjs/storybook#0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-09-17T08:11:47.196Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Mock all required properties and methods that the test subject uses
Learnt from: CR
PR: storybookjs/storybook#0
File: .cursorrules:0-0
Timestamp: 2025-09-17T08:11:04.287Z
Learning: Applies to code/**/*.{test,spec}.{ts,tsx} : Name test files as *.test.ts, *.test.tsx, *.spec.ts, or *.spec.tsx
Learnt from: CR
PR: storybookjs/storybook#0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-09-17T08:11:47.197Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Group related mocks together
Learnt from: CR
PR: storybookjs/storybook#0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-09-17T08:11:47.196Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Use vi.mock() with the spy: true option for all package and file mocks in Vitest tests
Learnt from: CR
PR: storybookjs/storybook#0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-09-17T08:11:47.196Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Use vi.mocked() to type and access mocked functions

@JReinhold JReinhold merged commit 764c7c2 into storybookjs:next Oct 1, 2025
52 of 53 checks passed
@github-actions github-actions bot mentioned this pull request Oct 1, 2025
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:normal maintenance User-facing maintenance tasks svelte

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants