You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 20, 2020. It is now read-only.
When importing a type or interface from a different file, docgen won't display props correctly (or at all).
To Reproduce
Import an interface from a separate file. Use that in type declaration of component.
types/bootstrap.ts
export interface DropdownProps {
/** Title to display in ActionSheet */
action_sheet_title?: string
/** URL to display alongside ActionSheet title */
action_sheet_title_image?: string
/** If this value matches an option's eventKey value, it will
* render as selected
*/
selectedKey?: string
}
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
export interface DropdownProps {
/** Title to display in ActionSheet */
action_sheet_title?: string
/** URL to display alongside ActionSheet title */
action_sheet_title_image?: string
/** If this value matches an option's eventKey value, it will
* render as selected
*/
selectedKey?: string
}
export const Dropdown: FC<DropdownProps> = (props) => {
...
}
Results in:
Code snippets
System:
package.json
"react-docgen-typescript-loader": "^3.6.0",
Component is in TSX format.
Please paste the results of npx -p @storybook/cli@next sb info here.
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"),},},],
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.
The text was updated successfully, but these errors were encountered: