Previously (v6.5), JSDoc @type annotations on Svelte component parameters were correctly translated to automatically build the argTypes for component stories. In particular, types that defined multiple options were translated to radio buttons.
For example, given the component parameter:
/**
* @type {'small' | 'medium' | 'large'} How large should the button be?
*/
export let size = 'medium';
Storybook v6.5 would generate a radio button control with 3 options, without the need for a manual argTypes definition in the stories file. With v7, a radio button is still identified as the appropriate control but an error occurs and no options are provided to the radio button control.
While investigating, I was able to uncover sveltedoc-parser still correctly parses the Svelte component and identifies the JSDoc annotations, interpreting the size parameter as a union type, same as before (this 3rd party package hasn't been updated in over a year). Further, the extractArgTypes function in the svelte renderer appears to identify the control type as a radio button with the appropriate set of options. However, somewhere down stream of extractArgTypes the options get lost. The front-end outputs a console log message stating "Radio with no options: size".
To Reproduce
https://github.com/michaelstachowiak/storybook-v7-svelte-issue
To reproduce, you can just create the reproduction for svelte and comment out the manual `argTypes` definition for button sizes, which I've done in the public repository above. In v6.5 it would have correctly generated a radio button, in v7 it encounters the error outlined above.
Output from extractArgTypes for the individual argument. Given this output, it is unclear to me why the radio button doesn't render any options, the appear to have been extracted correctly.
Describe the bug
Previously (v6.5), JSDoc
@type
annotations on Svelte component parameters were correctly translated to automatically build the argTypes for component stories. In particular, types that defined multiple options were translated to radio buttons.For example, given the component parameter:
Storybook v6.5 would generate a radio button control with 3 options, without the need for a manual
argTypes
definition in the stories file. With v7, a radio button is still identified as the appropriate control but an error occurs and no options are provided to the radio button control.While investigating, I was able to uncover
sveltedoc-parser
still correctly parses the Svelte component and identifies the JSDoc annotations, interpreting thesize
parameter as aunion
type, same as before (this 3rd party package hasn't been updated in over a year). Further, theextractArgTypes
function in the svelte renderer appears to identify the control type as a radio button with the appropriate set of options. However, somewhere down stream ofextractArgTypes
the options get lost. The front-end outputs a console log message stating "Radio with no options: size".To Reproduce
System
Additional context
Output from
extractArgTypes
for the individual argument. Given this output, it is unclear to me why the radio button doesn't render any options, the appear to have been extracted correctly.