Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Story/Meta typings for Svelte #19031

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/svelte/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export {
raw,
} from './preview';

export * from './preview/types-6-0';

if (module && module.hot && module.hot.decline) {
module.hot.decline();
}
41 changes: 41 additions & 0 deletions app/svelte/src/client/preview/types-6-0.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import type {
AnnotatedStoryFn,
Args,
ComponentAnnotations,
StoryAnnotations,
} from '@storybook/csf';

export type { Args, ArgTypes, Parameters, StoryContext } from '@storybook/csf';

import type { SvelteFramework } from './types';

/**
* Metadata to configure the stories for a component.
*
* @see [Default export](https://storybook.js.org/docs/formats/component-story-format/#default-export)
*/
export type Meta<TArgs = Args> = ComponentAnnotations<SvelteFramework, TArgs>;

/**
* Story function that represents a CSFv2 component example.
*
* @see [Named Story exports](https://storybook.js.org/docs/formats/component-story-format/#named-story-exports)
*/
export type StoryFn<TArgs = Args> = AnnotatedStoryFn<SvelteFramework, TArgs>;

/**
* Story function that represents a CSFv3 component example.
*
* @see [Named Story exports](https://storybook.js.org/docs/formats/component-story-format/#named-story-exports)
*/
export type StoryObj<TArgs = Args> = StoryAnnotations<SvelteFramework, TArgs>;

/**
* Story function that represents a CSFv2 component example.
*
* @see [Named Story exports](https://storybook.js.org/docs/formats/component-story-format/#named-story-exports)
*
* NOTE that in Storybook 7.0, this type will be renamed to `StoryFn` and replaced by the current `StoryObj` type.
*
*/
export type Story<TArgs = Args> = StoryFn<TArgs>;
14 changes: 14 additions & 0 deletions app/svelte/src/client/preview/types-7-0.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { Args } from '@storybook/csf';

import type { StoryObj } from './types-6-0';

export type { StoryFn, StoryObj, Meta } from './types-6-0';

// NOTE these types are reversed from the way they are in types-6-0 and types-6-3

/**
* Story function that represents a CSFv3 component example.
*
* @see [Named Story exports](https://storybook.js.org/docs/formats/component-story-format/#named-story-exports)
*/
export type Story<TArgs = Args> = StoryObj<TArgs>;
1 change: 1 addition & 0 deletions app/svelte/types-6-0.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './dist/client/preview/types-6-0';