strothj / react-docgen-typescript-loader

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

Support for defaultProps declaration #36

Closed caspg closed 5 years ago

caspg commented 5 years ago

Typescript 3.0 added support for react's defaultProps declaration click.

Is there any plan to support it in this loader?

interface ButtonProps {
  children: string
  disabled: boolean
}

Button.defaultProps = {
  disabled: false,
}

export function Button(props: ButtonProps) {
  return (
    <button className={styles.button}>
      {props.children}
    </button>
  )
}

Would be cool if disabled props would be marked as optional.

fmal commented 5 years ago

Would love to see this supported too, @strothj i guess this would have to be handled within https://github.com/styleguidist/react-docgen-typescript?

strothj commented 5 years ago

Yes, I believe this will need to be handled by that parser package.

There’s an existing issue for it here: https://github.com/styleguidist/react-docgen-typescript/issues/129