Skip to content
This repository has been archived by the owner on Nov 20, 2020. It is now read-only.

Doesn't support union types #81

Open
jeffcstock opened this issue Jan 10, 2020 · 7 comments
Open

Doesn't support union types #81

jeffcstock opened this issue Jan 10, 2020 · 7 comments

Comments

@jeffcstock
Copy link

jeffcstock commented Jan 10, 2020

Consider the following:

Working, no union type

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

image

Broken when union type (&) used

export const Button = (
  props: ButtonProps & React.HTMLAttributes<HTMLButtonElement>
) => { ... }

image

Any help would be much appreciated.

@NathanDeveloping
Copy link

The same problem is occuring to me. I'm using interface and inheritance as a workaround.

It might be cool to be able to distinguish props & extended props too.

@kennycrosby
Copy link

@NathanDeveloping I am running into this as well, can you elaborate on your workaround?

@YozhEzhi
Copy link

@jeffcstock Sorry for offtop, but how you styled TS docs so beauty? :)

Where I can find info to make my docs as pretty as yours? Thanks.

@kennycrosby
Copy link

@YozhEzhi I believe he is using this addon: https://www.npmjs.com/package/@storybook/addon-docs

@YozhEzhi
Copy link

@kennycrosby I think you're right. Thanks!

@NathanDeveloping
Copy link

@kennycrosby, with your example :

export interface ButtonProps extends React.HTMLAttributes<HTMLButtonElement> {
// extra button props
}

export const Button: React.FunctionComponent<ButtonProps> = ({
 // props decomposed
}) => { ... }

In this way, doc generation works.

@dancingshell
Copy link

I also have used React.FC in this case and it works

export const Button: React.FunctionComponent<ButtonProps & React.HTMLAttributes<HTMLButtonElement>> = (props) => {...}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants