Open woodyrew opened 5 months ago
This is unrelated to @storybook/addon-svelte-csf
as this is an issue with regular CSF as well, so I've transferred it to the Storybook monorepo.
TypeScript types have never been supported, so I consider this a feature request and rather than a bug.
There isn't proper tooling in the Svelte community to get prop types from a TS-typed Svelte-component, so we're blocked on the Svelte team or community providing such a tool. Eg. Vue has vue-component-meta
, Svelte doesn't have anything similar AFAIK.
Thanks for providing more context around this and putting it in the right place.
There isn't proper tooling in the Svelte community to get prop types from a TS-typed Svelte-component
Could we not use the Svelte ComponentProps for the prop types?
Could we not use the Svelte ComponentProps for the prop types?
They are only TypeScript-level types, they can't be used to generate anything at runtime, as types are stripped away.
Years of experience have taught us that this specific problem is best solved by the specific framework's communities, as attempting to solve it within Storybook is biting of more than we can chew. Here are a few examples:
We're hoping that eventually the Svelte team will provide an API like this, but currently they have their hands full with the release of v5, which makes sense. The Svelte Language Server must do this computation internally to work, however its not exposed as an API, and Storybook's architecture isn't built to be able to interact with a language server.
Describe the bug
The Typescript types in a Svelte component don't come through to the props table in Storybook.
Steps to reproduce the behaviour
MyComponent.svelte
MyComponent.stories.svelte
any
"My title"
string
Default value
Another title
string
titled
any
. Unlesslang=ts
removedstring
The last one
Note: with the
title
showing typeany
in Storybook, the control is an Object so the UX is poor.Expected behaviour
The expected behaviour would be that the
title
in the Storybook Properties table would have the correct type and associated control.Environment
@storybook/addon-svelte-csf
: "4.1.3"