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

(documentation) Add a "troubleshooting" section to typescript.md #14965

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions docs/configure/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: 'TypeScript'
---

Storybook has built-in Typescript support, so your Typescript project should work with zero configuration needed.
Storybook has built-in Typescript support, so your Typescript project should work with zero configuration needed. The config files from `.storybook` can be in TypeScript as well.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Offirmo if you could revert back to what's currently documented we'd appreciate it. The reasoning behind this is that in the first sentence we're mentioning that Storybook as a whole has Typescript support, despite the config files being created with .js extension.


### Default configuration

Expand Down Expand Up @@ -61,4 +61,17 @@ Next time you restart your Storybook the extra props will also be in the UI.

<div class="aside">
If you run into an issue where the extra props aren't included, check how your component is being exported. If it's using a default export, change it to a named export and the extra props will be included as well.
</div>
</div>

### Troubleshooting

If storybook is not picking up TypeScript errors, ensure:
* you have a `tsconfig.json` ([ref](https://github.com/storybookjs/storybook/issues/14118#issuecomment-794698889))
* `tsconfig.json` is properly including your files, including `*.tsx`. Example: `"include": [ "stories/**/*" ]`
* Eventually, run with additional traces: `DEBUG=docgen:include,docgen:exclude yarn storybook` to check if your files are properly processed

If react docgen is not generating doc based on types, ensure:
* TypeScript is properly configured (see above)
* You don't have TypeScript errors

If using React, if you need help to properly type your components, this site may help: https://react-typescript-cheatsheet.netlify.app/
Comment on lines +66 to +77
Copy link
Contributor

@jonniebigodes jonniebigodes Jun 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Offirmo we have a bit of improvement here we can probably go with:

### Troubleshooting

If you run into issues with TypeScript and Storybook, ensure that:

- Your project contains a `tsconfig.json` file at the root level
- `tsconfig.json` is set up to handle Typescript files (e.g., `"include": [ "stories/**/*.tsx" ]`)
- Follow the [debugging instructions](https://github.com/hipstersmoothie/react-docgen-typescript-plugin#debugging) to check if the story files are processed

<div class="aside">
 💡 <strong>Note:</strong> If you need help setting up TypeScript in your project, check the <a href="https://www.typescriptlang.org/">Typescript docs</a>.
</div>

The reasoning behind this is that we can shorten the section and prevent repetition. Thus making the documentation a bit more streamlined.