Skip to content

Commit

Permalink
Merge branch 'next' into optional-children-type
Browse files Browse the repository at this point in the history
  • Loading branch information
xeho91 committed Oct 17, 2024
2 parents 3ae0e5a + 37013cf commit f10113b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ describe("component 'Story' destructured from 'defineMeta", () => {

expectTypeOf(Story).toMatchTypeOf<StoryCmp<EmptyObject, typeof Button, Meta<typeof Button>>>();
expectTypeOf<TStoryProps>().not.toBeNever();
expectTypeOf<ComponentProps<Button>['children']>().not.toBeNullable();
expectTypeOf<Meta<typeof Button>['args']>().toBeNullable();
expectTypeOf<NonNullable<Meta<typeof Button>['args']>['children']>().toBeNullable();
expectTypeOf<TStoryProps>().toHaveProperty('name');
Expand Down
6 changes: 5 additions & 1 deletion tests/stories/Example.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@
setTemplate(render);
</script>

{#snippet render(args: Args<typeof Story>, context: StoryContext<typeof Story>)}
<!--
FIXME: Temporary workaround.
Need to find a way on how to convert children type from `Snippet | Primitive` to `Snippet | undefined`
-->
{#snippet render({ children: _, ...args }: Args<typeof Story>, context: StoryContext<typeof Story>)}
<Example {...args} onclick={handleClick}>
<p>{args.id}</p>
<p>{context.name}</p>
Expand Down
6 changes: 2 additions & 4 deletions tests/stories/Example.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<script lang="ts">
import type { Snippet } from 'svelte';
import type { HTMLAttributes } from 'svelte/elements';
import type { HTMLButtonAttributes } from 'svelte/elements';
interface Props extends HTMLAttributes<HTMLButtonElement> {
children?: Snippet;
interface Props extends HTMLButtonAttributes {
rounded?: boolean;
}
Expand Down

0 comments on commit f10113b

Please sign in to comment.