Skip to content

Add more information about parent declaration #312

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

opcode0x
Copy link
Contributor

@opcode0x opcode0x commented Dec 3, 2020

Summary

As a developer I would like to have extended information about property type declaration. As some of props could be described as an inheritance of types in node_modules it's impossible to opt in such props in propFilter function and opt out all the props from node_modules.

Example

import { FC, PropsWithRef } from 'react';

type HTMLButtonProps = JSX.IntrinsicElements['button'];

type Props = HTMLButtonProps & {
  /** onClick event handler */
  onClick?: HTMLButtonProps['onClick'];
};

const ButtonWithOnClickComponent: FC<Props> = props => {
  return <button {...props} />;
};

export default ButtonWithOnClickComponent;

Current version of react-docgen-typescript will generate next prop description

{
   onClick: {
     // ... 
    parent: {
        fileName: "node_modules/@types/react/index.d.ts",
        // ...
    }
  }
}

Proposal

Provide an ability to retrieve all the parent declarations of prop. I have specified an additional parents field to the prop declaration that exposes all the Node declarations that typescript handles.

@opcode0x
Copy link
Contributor Author

opcode0x commented Dec 9, 2020

@pvasek Hello, could you give feedback, please?

Copy link
Collaborator

@pvasek pvasek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, it seems to be fine. The main issue is that there is no example of what to expect in parents.

@opcode0x
Copy link
Contributor Author

@pvasek I've updated PR

@pvasek pvasek merged commit 4c708b3 into styleguidist:master Jan 3, 2021
@opcode0x opcode0x deleted the feat/add-parents-prop-information branch January 3, 2021 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants