Open federico-ntr opened 5 months ago
I also encounter the problem when i use forwardRef
from react:
const ReactComponent = forwardRef<HTMLDivElement, MyProps>(props, ref) => { ... };
There aren't description content in controls tab and i see uknown
type on some arguments.
So i have to assign the type to props
argument explicitly to get it working well:
const ReactComponent = forwardRef<HTMLDivElement, MyProps>(props: MyProps, ref) => { ... };
I also hit this issue while using forwardRef
(repro: https://stackblitz.com/edit/github-rccvwa?file=src%2Fstories%2FForwardedButton.stories.ts).
This is extremely problematic for component libraries because after upgrading to v8 we lost lots of documentation.
This is related to https://github.com/storybookjs/storybook/issues/26496
Following examples are for:
export type SurfaceProps = {
children: ReactNode;
/** Background of the surface box */
background?: (typeof SurfaceBackgrounds)[number];
/** Corner rounding of the surface box */
radius?: (typeof SurfaceRadii)[number];
/** Size of the box shadow. Takes and integer, Bigger value, bigger size of the shadow */
elevation?: number;
/** Show border around the surface box */
hasBorder?: boolean;
/**
* Switch color scheme for light or dark backgrounds
*
* @deprecated Replaced with design tokens for using dark mode add .dark classname
* to Surface or its parent
*/
mode?: (typeof SurfaceMode)[number];
} & ComponentPropsWithoutRef<'div'>;
const Surface = forwardRef<HTMLDivElement, SurfaceProps>(( props, ref ) => {
...
);
{ typescript: { reactDocgen: "react-docgen-typescript" } }
const Surface = forwardRef<HTMLDivElement, SurfaceProps>((props: SurfaceProps, ref) => {
)
Describe the bug
After the latest major update, which brings the new autodocs package
react-docgen
, the doc table of all of my stories is missing pieces of information. Before it was populating the Description column with the JSDocs of component's props' interface:Resulted in:
After the update it looks like this:
As you can see the text I wrote in the JSDocs is missing and the type of the two props with a default is not correctly inferred.
While trying to create a repro I discovered that the issue lies in the use of utility type
Readonly<T>
. You can open the repro and see docs for Button are badly generated. RemoveReadonly
and restart sb, you'll see they'll be correctly generated. As a workaround I switched to the oldreact-docgen-typescript
which is handlingReadonly
correctly.To Reproduce
https://stackblitz.com/edit/github-inlxfv?file=src%2Fstories%2FButton.tsx
System
Additional context
No response