[Svelte] Storybook autodocs + svelte 5 #34104
Replies: 2 comments 3 replies
-
|
Hi @tobiasBora! I'm Dosu and I’m helping the storybook team. Storybook does support Svelte 5 autodocs, but there's an important limitation: For documenting $props, use JSDoc or TypeScript comments on your props interface: interface Props {
/** The name of the user */
name: string;
/** The user's age (optional) */
age?: number;
}
let { name, age = 25 }: Props = $props();This will generate an args table showing types, descriptions, and default values. Type inference from TypeScript is supported and enabled by default in Make sure you're on Storybook 8.4+ which introduced improved Svelte TypeScript support. Could you share:
This will help determine if there's a configuration issue or a specific bug at play. To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
-
|
@tobiasBora Svelte 5 support is still maturing in Storybook.
/**
* My component description
*/
<script lang="ts">
interface Props {
/** Prop description */
foo: string;
}
let { foo }: Props = $props();
</script>If that fails, using |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
I feel really dumb but I can't find where to write the documentation for my svelte 5 (sveltekit) components so that it is picked by
autodocsin storybook. I tried for instance to write:at the top of my component but it is not recognized since I can still only read "More on writing stories with args: https://storybook.js.org/docs/writing-stories/args" at the top of my component. I also tried:
in the typescript block without luck. Similarly, how am I supposed to document $props? Can I write some doc in the typescript type and make it visible in the doc itself? It seems like storybook can't infer the type from the typescript itself.
I tried to go in https://github.com/storybookjs/storybook/tree/next/code/addons/docs/docs/frameworks but svelte is not listed there in the list of frameworks.
Additional information
No response
Create a reproduction
No response
Beta Was this translation helpful? Give feedback.
All reactions