-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
|
||
### Default configuration | ||
|
||
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.