Incorrect JSDoc for React component description in docs/mcp addons with Object.assign()
#34351
-
SummaryQuestion—with the new mcp addon, I have several components that are setup basically like this: // Component.tsx
const ComponentElement = forwardRef((props, ref) => return <ComponentThings {...props} ref={ref} />);
const ComponentGroup = (props) => return <ComponentThings {...props} ref={ref} />;
/** Component Description **/
export const Component = Object.assign(ComponentElement, {
/** Component.Group Description **/
Group: ComponentGroup,
});// Component.stories.tsx
import { Component } from "./Component";
import type { Meta, StoryObj } from "@storybook/react-vite";
const meta = {
title: "Component",
component: Component,
tags: ["autodocs"],
} satisfies Meta<typeof Component>
export default meta;
export const Demo: StoryObj<typeof Component> = {};The placement of the JSDoc comments works correctly with IDE/intellisense and other tools, but in my component manifest from the Storybook MCP addon, I see:
I can also see if I enable the Storybook docs addon that it also uses the If I duplicate the JSDoc comment above the Is this the intended behavior, or should I submit this as a bug? I'd prefer to not have to write the JSDocs twice for IDE/Storybook Additional informationStorybook version I attempted to create a repro using the StackBlitz template, but I can't get it to run even without any changes. But I'll paste it below and maybe someone else can figure out what's wrong. Create a reproductionhttps://stackblitz.com/edit/github-5ekvmq2m?file=src%2Fstories%2FButton.tsx |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
|
Hi @w-a-t-s-o-n! I'm Dosu and I’m helping the storybook team. This is a limitation of the default You can try enabling the experimental export default {
features: {
experimentalReactComponentMeta: true
}
}This uses TypeScript's LanguageService API (the same API that powers IDE autocomplete), so it should extract JSDoc from where your IDE does. It achieved 100% component detection on 15 Object.assign compound components in the Primer design system. Please test and let us know if that resolves the issue for your components. To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
@dosu I found a workaround to fix this, even without the experimental flag. Instead of having a separate
ComponentElement, inlining theObject.assignfixes it. I'll leave this here in case someone else runs into this: