atlassian / extract-react-types

One stop shop for documenting your react components.
https://atlassian.github.io/extract-react-types/
MIT License
179 stars 28 forks source link

Extended union not showing #103

Closed studiorabota closed 4 years ago

studiorabota commented 5 years ago

Hi,

When extending the type with an union & (DivProps | AnchorProps) this does not show in <PrettyPropTypes />.

The data is available in the response of extract-react-types-loader. Only kind2string does not know how to deal with this data was expecting to reduce to an object and could not {kind: "union", types: Array(2)}

Component:

export type AnchorProps = JSX.IntrinsicElements['a']
export type ButtonProps = JSX.IntrinsicElements['button']

export type ComponentProps = GlProgressStepBaseProps & (AnchorProps | ButtonProps)

const Component = (props: ComponentProps) => {}

Data returned from extract-react-types-loader:

{
  "kind": "union",
  "types": [
    {
      "kind": "generic",
      "value": {
        "kind": "generic",
        "value": {
          "kind": "id",
          "name": "JSX.IntrinsicElements['a']"
        },
        "referenceIdName": "AnchorProps"
      }
    },
    {
      "kind": "generic",
      "value": {
        "kind": "generic",
        "value": {
          "kind": "id",
          "name": "JSX.IntrinsicElements['button']"
        },
        "referenceIdName": "ButtonProps"
      }
    }
  ]
}

I'm happy to submit a PR for this, just wanted to see if that would be something you'd be open to supporting? And perhaps you have some ideas on how this should be solved?

Thanks! And many thanks for creating these awesome packages.

Noviny commented 5 years ago

Hi @studiorabota would be happy to look at a PR to solve this, and thanks for the nice words 😄

studiorabota commented 4 years ago

hi @Noviny , sorry for the late reply. There's been some change in requirements and our team decided to stick to an already existing implementation for displaying prop documentation. Unfortunately therefore I also don't have time to make this PR. My apologies.