Storybook: No props table appear within docs on typescript when exported from another file

Created on 1 May 2020  路  6Comments  路  Source: storybookjs/storybook

Describe the bug
It seems like unless the types are in the same file as the Component, it is not shown within @addons/docs prop section.

To Reproduce
The code below for a react component SHOWS props within the docs section.
Button.tsx:

...

type ButtonProps = {
  title?: string;
  appearance?: 'primary' | 'inverse' | 'invisible';
};

const Button: FC<ButtonProps> = (props: ButtonProps) => {
...
}

Button.stories.tsx:

import React from 'react';
import Button from './Button';

export default {
  title: 'Elements|Button',
  component: Button
};

const Basic = () => <Button title="test" />

But if I move the ButtonProps type to another file, types table does not work:

...
import { ButtonProps } from './ButtonModels';
const Button: FC<ButtonProps> = (props: ButtonProps) => {
...
}

Expected behavior
Regardless of where the types are exported from, types table should show?

Screenshots
image
When types exported:
image

docs react props inactive question / support typescript

Most helpful comment

A few weeks ago we released zero-config typescript support in 6.0-beta, and then a few days ago upgraded react-docgen-typescript-loader to react-docgen-typescript-plugin in the latest beta. This will solve many typescript props-related issues, possibly including this one:

Please try it out!

All 6 comments

Documented here: https://github.com/storybookjs/storybook/blob/next/addons/docs/docs/props-tables.md#imported-types

This is supported byreact-docgen-typescript and we'll be making it easier to switch between the two as a consequence of this shortcoming in react-docgen.

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

A few weeks ago we released zero-config typescript support in 6.0-beta, and then a few days ago upgraded react-docgen-typescript-loader to react-docgen-typescript-plugin in the latest beta. This will solve many typescript props-related issues, possibly including this one:

Please try it out!

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

moimikey picture moimikey  路  67Comments

43081j picture 43081j  路  61Comments

hckhanh picture hckhanh  路  69Comments

tycho01 picture tycho01  路  76Comments

ChucKN0risK picture ChucKN0risK  路  74Comments