Closed jeffcstock closed 4 years ago
Any news about this issue?
This loader unfortunately does not automatically locate your project's tsconfig.json file (would be a great enhancement if a pull request is made).
If its path isn't specified, the underlying library react-docgen-typescript
will fallback to creating a new TypeScript project for each file (I believe), which unfortunately does not resolve types external to the file being checked.
I've updated the documentation and updated the example project to show its usage:
use: [
require.resolve("ts-loader"),
{
loader: require.resolve("react-docgen-typescript-loader"),
options: {
// Provide the path to your tsconfig.json so that your stories can
// display types from outside each individual story.
tsconfigPath: path.resolve(__dirname, "../tsconfig.json"),
},
},
],
Thank you so much @strothj that is exactly the fix I needed. Thanks for updating the docs, i'm sure it will help others in my situation! 🎉
Describe the bug
When importing a type or interface from a different file, docgen won't display props correctly (or at all).
To Reproduce
types/bootstrap.ts
Dropdown.tsx
Expected behavior
The Props block should display the corresponding Props.
Actual Behaviour
The props block doesn't display any props.
Fix
However, the props will show correctly if the interface is declared in the same file as the component.
Dropdown.tsx
Results in:
Code snippets
System:
package.json
Component is in TSX format.
Please paste the results of npx -p @storybook/cli@next sb info here.