Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StoryDecorator and RenderFunction need to be exported. #8160

Closed
rakeshpai opened this issue Sep 23, 2019 · 10 comments
Closed

StoryDecorator and RenderFunction need to be exported. #8160

rakeshpai opened this issue Sep 23, 2019 · 10 comments

Comments

@rakeshpai
Copy link

Migrating to 5.2.x has caused build errors in my TS project:

node_modules/@types/storybook__addon-info/index.d.ts:10:10 - error TS2305: Module '"path/to/project/node_modules/@storybook/react/dist/client"' has no exported member 'RenderFunction'.

10 import { RenderFunction, StoryDecorator } from '@storybook/react';
            ~~~~~~~~~~~~~~

node_modules/@types/storybook__addon-info/index.d.ts:10:26 - error TS2305: Module '"path/to/project/node_modules/@storybook/react/dist/client"' has no exported member 'StoryDecorator'.

10 import { RenderFunction, StoryDecorator } from '@storybook/react';
                            ~~~~~~~~~~~~~~

node_modules/@types/storybook__addon-knobs/index.d.ts:13:10 - error TS2305: Module '"path/to/project/node_modules/@storybook/react/dist/client"' has no exported member 'RenderFunction'.

13 import { RenderFunction } from '@storybook/react';
            ~~~~~~~~~~~~~~

node_modules/@types/storybook__addon-viewport/index.d.ts:7:10 - error TS2305: Module '"path/to/project/node_modules/@storybook/react/dist/client"' has no exported member 'StoryDecorator'.

7 import { StoryDecorator } from '@storybook/react';
           ~~~~~~~~~~~~~~

It looks like StoryDecorator and RenderFunction need to be exported from @storybook/react.

Expected behavior
Addons with TS should Just Work.

@rakeshpai
Copy link
Author

Possibly related: #8121

@ndelangen
Copy link
Member

You were using https://www.npmjs.com/package/@types/storybook__react before?

You should now get types without it, so there should be no need to import RenderFunction or StoryDecorator anymore.

@rakeshpai
Copy link
Author

I was, but I've removed @types/storybook__react now. It looks like these errors aren't from my code though. It seems to be originating from the addons. So I'm not sure if this is anything I can do to fix, but I'll be happy to stand corrected.

@ndelangen
Copy link
Member

Please remove @types/storybook__addon-info too, it's types will be incorrect.

I'd recommend migrating to the docs addon, which has types!

@rakeshpai
Copy link
Author

rakeshpai commented Sep 23, 2019

Thanks, @ndelangen. I tried removing @types/storybook__addon-info, but addon-info's package.json doesn't have a types field, so its types aren't picked up automatically. https://unpkg.com/@storybook/addon-ionfo@5.2.1/package.json This is also true of the viewport addon. https://unpkg.com/@storybook/addon-viewport@5.2.1/package.json

Migrating to the docs addon is on the cards (it looks awesome!), but I was hoping to keep things working as I'm migrating.

@ndelangen
Copy link
Member

@rakeshpai The viewport addon doesn't need any types. It's a register only addon.

Previously users would import a withViewport, but this has been deprecated.

The addon info is unofficially deprecated. We will not add types to it.
I recommend you silence the build error using some custom typescript code or any.

You could also take ownership of the @types/storybook__addon-info package and fix it, if you'd like. or use it as a starter to create a locally defined types for the package.

@rakeshpai
Copy link
Author

Sorry, deleted my last comment, it was incorrect. I'll update this thread with my latest findings.

@rakeshpai
Copy link
Author

Closing this issue since the specifics above have been resolved by removing the @types/... packages.

However, this hasn't been a smooth migration. I couldn't get addon-info working (due to the types issue above), and I couldn't get addon-docs working because of #7829. As a result, I've now lost my old addon-info-based documentation, and don't have any addon-docs-based documentation. I've had to roll-back to 5,1 as a result.

I'll revisit the migration once 5.2 support for TS is more solid. Cheers!

@shilman
Copy link
Member

shilman commented Sep 24, 2019

@rakeshpai we'll try to resolve the addon-docs typescript support soon in 5.3! you should also just be able to disable source code in docs for now as a workaround?

@good-idea
Copy link
Contributor

good-idea commented Sep 24, 2019

@rakeshpai , I'm able to get this to work in 5.2 if my storybook config file is .js

(scratch that, nevermind)

danhuang1202 pushed a commit to danhuang1202/react-aspect-ratio-img that referenced this issue Oct 13, 2019
danhuang1202 pushed a commit to danhuang1202/react-aspect-ratio-img that referenced this issue Oct 13, 2019
## <small>2.0.3 (2019-10-13)</small>

* fix: remove storybook_addon-info base on storybookjs/storybook#8160 ([ee50893](ee50893))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants