strothj / react-docgen-typescript-loader

Webpack loader to generate docgen information from Typescript React components.
Other
360 stars 47 forks source link

Importing component defined in index breaks the docgen #84

Open NathanDeveloping opened 4 years ago

NathanDeveloping commented 4 years ago

doesn't work :

index.tsx

import * as React from 'react';

export interface AProps {
  name?: string;
}

const A: React.FunctionComponent<AProps> = ({name}) => {
  return <p>{name}</p>;
};

A.displayName = 'A';

export {A};

a.story.mdx

import {Meta, Story, Preview, Props} from '@storybook/addon-docs/blocks';
import {A} from '.';  // <------------------

<Meta title="A" component={A} />

<Story name="Default">
  <A name="pelo" />
</Story>

<Props of={A} />

works:

A.tsx

same as index.tsx above

a.story.tsx

import {A} from './A'; // <------------------

<Meta title="A" component={A} />

<Story name="Default">
  <A name="pelo" />
</Story>

<Props of={A} />
NathanDeveloping commented 4 years ago

It seems that component files named with hypen cannot be parsed too