storybookjs/addon-svelte-csf

[Bug] Broken types - @storybook/types issue

Closed this issue · 8 comments

Describe the bug

At some points between 8.0.10 and 8.2.6, something changed with how types are handled internally in the storybook. More specifically, I've seen that generally types are now imported from storybook/internal/types rather than @storybook/types. The issue here is that it seems like the package @storybook/types is not a dependency of other storybook packages anymore, and addon-svelte-csf also doesn't depend on it (only through devDependencies, which are not propagated), so the types package is not installed anymore.

This means that any code that imports from @storybook/types, including library code like addon-svelte-csf, fails. More specifically I'm talking about this one line of code:

import type { Addon_BaseMeta as BaseMeta, Addon_BaseAnnotations as BaseAnnotations, StoryContext, WebRenderer } from '@storybook/types';

Steps to reproduce the behavior

  1. Any project that uses Storybook 8.2.6 and addon-svelte-csf 4.1.4
  2. Make sure to not manually depend on @storybook/types
  3. Write a story - <Story args={...} />
  4. Seemengly random/weird errors:
Error: Object literal may only specify known properties, and 'args' does not exist in type 'Partial<StoryProps>'. (ts)
    const controls: Partial<StoryProps> = {
        args: {
            creating: false,

The problem is that, inside addon-svelte-csf, StoryProps extends BaseAnnotations from @storybook/types, which declares args, argTypes and many others. But, as the package is not installed, TypeScript doesn't find the interface it's supposed to extend. The extends statement fails silently, causing StoryProps to practically not extend anything anymore, and instead errors appear in the end-user code, like the one above.

Workaround

Manually add @storybook/types as a dependency.

Which version of @storybook/addon-svelte-csf are you using?

My bad, forgot to mention. This issue happened after updating everything to the latest version, so that would be 4.1.4.

@ndelangen do you agree here that the solution is just to move @storybook/types to a regular dependency, as we need to support all of 8.X?

note this addon doesn't use the blessed tsup setup due to.. Svelte-related reasons.

Had this happen on our system after an update. I'm using 4.1.4 for CSF and 8.2.7 of Storybook. Workaround fixed it for us.

This is likely fixed in the latest patch version of storybook @JReinhold

This is likely fixed in the latest patch version of storybook @JReinhold

No, like I say in my comment, I'm using 8.2.7 (which is the latest version as I type this) and I need to install the @storybook/types library as a workaround to no longer get the errors.

This is likely fixed in the latest patch version of storybook @JReinhold

No this addon still depends on the types package even though the issue is fixed in core. The types package is still missing.

🚀 Issue was released in v4.1.5 🚀