react-docgen-typescript
react-docgen-typescript copied to clipboard
Explicit types ignored in favor of underlying, implicit types
If I have some component:
const BaseButton = (props: BaseButtonProps) => <button {...props} />;
const StyledButton = styled(BaseButton)``;
export type ButtonProps = {}; // unimportant
export const Button = (props: ButtonProps) => <StyledButton {...props} />;
and I import Button into a Storybook file like so:
const meta: Meta<ButtonProps> = {
component: Button,
title: '/Button',
};
My Storybook instance (using react-docgen-typescript) will populate the table with props from BaseButtonProps. Not ButtonProps.It can lead to incorrect documentation if - for example - I Omit or Pick props from the Base* Props to define a different set of Props for the component being extended.
Why does it do this? Why doesn't docgen instead simply render tables based upon the type that the item is on import?