diff --git a/.storybook/main.ts b/.storybook/main.ts index 42b0898..789297b 100644 --- a/.storybook/main.ts +++ b/.storybook/main.ts @@ -3,14 +3,14 @@ import type { StorybookConfig } from '@storybook/svelte-vite'; const config: StorybookConfig = { stories: [ { - directory: '../stories', + directory: '../examples', files: '**/*.stories.@(ts|svelte)', - titlePrefix: 'Demo', + titlePrefix: 'Examples', }, { - directory: '../examples', + directory: '../tests/stories', files: '**/*.stories.@(ts|svelte)', - titlePrefix: 'Examples', + titlePrefix: 'Tests', }, ], framework: '@storybook/svelte-vite', diff --git a/src/index.test.ts b/src/index.test.ts index c36384d..2a5fcec 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -1,9 +1,9 @@ -import type { Component, ComponentProps } from 'svelte'; -import type { EmptyObject } from 'type-fest'; +import type { Component, ComponentProps, Snippet } from 'svelte'; +import type { EmptyObject, Primitive } from 'type-fest'; import { describe, expectTypeOf, it } from 'vitest'; import { defineMeta, type Args, type StoryContext } from '#index'; -import type { Meta, StoryCmp, StoryContext as BaseStoryContext } from '#types'; +import type { Meta, StoryAnnotations, StoryCmp, StoryContext as BaseStoryContext } from '#types'; import Button from '../examples/components/Button.svelte'; @@ -41,7 +41,10 @@ describe("type helper for snippets 'Args'", () => { }, }); - expectTypeOf>().toMatchTypeOf<(typeof meta)['args']>(); + expectTypeOf>().not.toBeNullable(); + expectTypeOf>().toMatchTypeOf['args']>(); + expectTypeOf['children']>().toMatchTypeOf(); + expectTypeOf['children']>().toBeNullable(); }); }); diff --git a/src/index.ts b/src/index.ts index 8581e01..5cd265a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,5 @@ import type { Args as BaseArgs } from '@storybook/types'; -import type { Component, ComponentProps, SvelteComponent } from 'svelte'; +import type { ComponentProps } from 'svelte'; import type { EmptyObject } from 'type-fest'; import type { @@ -8,6 +8,7 @@ import type { StoryContext as BaseStoryContext, PossibleCmpType, MapSnippetsToAcceptPrimitives, + StoryAnnotations, } from '#types'; import Story from './runtime/Story.svelte'; @@ -36,12 +37,12 @@ export function defineMeta< }; } -export type Args> = +export type Args = TStoryCmp extends StoryCmp - ? TMeta['args'] + ? NonNullable['args']> : never; -export type StoryContext> = +export type StoryContext = TStoryCmp extends StoryCmp ? BaseStoryContext : never; diff --git a/src/runtime/Story.svelte b/src/runtime/Story.svelte index 3fa6486..4b5bb56 100644 --- a/src/runtime/Story.svelte +++ b/src/runtime/Story.svelte @@ -10,9 +10,9 @@ import { useStoriesTemplate } from '#runtime/contexts/template.svelte'; import { storyNameToExportName } from '#utils/identifier-utils'; - import type { Meta, StoryAnnotations, StoryCmpProps, SvelteRenderer } from '#types'; + import type { Meta, StoryAnnotations, StoryCmpProps } from '#types'; - type Props = StoryAnnotations & { + type Props = Partial> & { /** * The content to render in the story, either as: * 1. A snippet taking args and storyContext as parameters diff --git a/tests/stories/Comparison.stories.ts b/tests/stories/Comparison.stories.ts index 2d92996..645bcca 100644 --- a/tests/stories/Comparison.stories.ts +++ b/tests/stories/Comparison.stories.ts @@ -23,7 +23,6 @@ const meta = { component: Comparison, argTypes: { csf: { table: { disable: true } }, - system: { table: { disable: true } }, }, tags: ['autodocs', '!dev'], } satisfies Meta; diff --git a/tests/stories/Templating.stories.svelte b/tests/stories/Templating.stories.svelte index d8da0d6..fc1d6f3 100644 --- a/tests/stories/Templating.stories.svelte +++ b/tests/stories/Templating.stories.svelte @@ -8,7 +8,6 @@ const { Story } = defineMeta({ title: 'Templating', tags: ['autodocs'], - args: { text: '' }, argsTypes: { text: { control: 'text' }, }, diff --git a/tests/stories/test/RequiredSnippet.stories.svelte b/tests/stories/test/RequiredSnippet.stories.svelte index 219a1bc..0585481 100644 --- a/tests/stories/test/RequiredSnippet.stories.svelte +++ b/tests/stories/test/RequiredSnippet.stories.svelte @@ -10,8 +10,8 @@ }); - - + + {#snippet children()}

This works

@@ -20,22 +20,12 @@ - {#snippet children()}

This works

{/snippet}
-

This works