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

Typescript: add types for react demo #8517

Merged
merged 2 commits into from
Oct 23, 2019

Conversation

Naturalclar
Copy link
Contributor

Issue:
When I use the demo story files generated by the cli, and change the file name from .stories.js to .stories.tsx, the two demo components provided in the react package causes the following error.

import {Welcome} from '@storybook/react/demo'; // Could not find a declaration file for module '@storybook/react/demo'. 

This is because the generated typings for the demo components are not included in the root folder of react, @storybook/react/demo

What I did

Added d.ts file for demo components in root directory of react.

How to test

Adding d.ts file in the root directory of react made the error go away, and the auto completion properly worked as expected.

files property in package.json includes *.d.ts, so this d.ts file will be included when user installs the @storybook/react package.

  • Is this testable with Jest or Chromatic screenshots? No
  • Does this need a new example in the kitchen sink apps? No
  • Does this need an update to the documentation? No

If your answer is yes to any of these, please make sure to include it in your PR.

@vercel
Copy link

vercel bot commented Oct 22, 2019

This pull request is being automatically deployed with ZEIT Now (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://zeit.co/storybook/monorepo/8t3jpa06y
🌍 Preview: https://monorepo-git-fork-naturalclar-chore-addtypesfordemo.storybook.now.sh

@ndelangen
Copy link
Member

Thank you @Naturalclar this is super useful!

Are you looking for some more typescript stuff to do?

There's lib/core that is mainly responsible for the dev server part of storybook that still needs to be migrated to typescript. I think that's still up for grabs if you'd be interested? 🙇

@ndelangen ndelangen merged commit 013f1fb into storybookjs:next Oct 23, 2019
@ndelangen ndelangen added this to the 5.3.0 milestone Oct 23, 2019
@Naturalclar
Copy link
Contributor Author

@ndelangen thanks for the info! I'd be happy to give it a try :)

@ndelangen
Copy link
Member

Are you on our discord? https://discord.gg/sMFvFsG

@shilman shilman changed the title chore: add types for react demo Typescript: add types for react demo Oct 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants