Skip to content

[Bug]: Named union types lose their values in get-documentation output #35778

Description

@rachelslurs

Describe the bug

Named union aliases lose their values between the manifest and get-documentation. Inline unions on the same component keep theirs.

In the reproduction, size and variant are both three-member string-literal unions. size refers to a named alias, variant declares its union inline. The manifest stores all three members for each:

size.type    = {"name":"enum","raw":"Size",
                "value":[{"value":"\"small\""},{"value":"\"medium\""},{"value":"\"large\""}]}
variant.type = {"name":"enum","raw":"\"primary\" | \"secondary\" | \"danger\"",
                "value":[{"value":"\"primary\""},{"value":"\"secondary\""},{"value":"\"danger\""}]}

get-documentation for the same component:

export type Props = {
  size?: Size = medium;
  variant?: "primary" | "secondary" | "danger" = primary;
}

code/lib/mcp/src/utils/parse-react-docgen.ts on next maps each prop with:

type: prop.type?.raw ?? prop.type?.name,

type.value holds the values in both cases and is never read. For an aliased prop raw is the alias name.

This is not specific to my code. cauldron shows it on its own docgen config, react-docgen-typescript with shouldExtractLiteralValuesFromEnum: true, which I did not touch. On develop at 4195dc (2026-08-04), Storybook 10.4.0, 4 of its 14 enum props come back as bare aliases. get-documentation for components-button:

export type Props = {
  variant?: "link" | "tag" | "primary" | "secondary" | "tertiary" | "error" | "danger" | "danger-secondary" | "badge" = primary;
  size?: TagSize;
  buttonRef?: Ref<HTMLButtonElement>;
  thin?: boolean;
}

variant returns all nine of its values in the same response where size stays opaque. The other three are Tag.size (TagSize), ImpactBadge.type (ImpactType), and Notice.icon (IconType). cauldron does not ship @storybook/addon-mcp, so I installed it at 0.7.0 to get a manifest.

Also reproduces in my own design system on Storybook 10.5.5 and 10.5.6. Across all three the MCP packages were @storybook/mcp 0.8.0 and @storybook/addon-mcp 0.7.0, so this is on the released latest rather than only on next.

I couldn't tell from #35677's diff whether the behavior survives the move to code/addons/mcp/.

An aliased enum could render its values when type.value has them. The default case stays open, since shouldExtractLiteralValuesFromEnum is false by default in react-docgen-typescript and type.value is empty there.

Reproduction link

https://github.com/rachelslurs/storybook-mcp-named-alias-repro

Reproduction steps

  1. npm ci
  2. npm run storybook
  3. ./verify.sh (runs assuming port 6006) in a second terminal

It prints the manifest rows for both props, then the rendered Props block. size returns Size with no values; variant returns all three.

System

Storybook Environment Info:

System:
  OS: macOS 26.5.2
  CPU: (10) arm64 Apple M1 Max
  Shell: 5.9 - /bin/zsh
Binaries:
  Node: 22.20.0 - ~/.nvm/versions/node/v22.20.0/bin/node
  Yarn: 1.22.22 - ~/.nvm/versions/node/v22.20.0/bin/yarn
  npm: 10.9.3 - ~/.nvm/versions/node/v22.20.0/bin/npm <----- active
  pnpm: 11.20.0 - /opt/homebrew/bin/pnpm
Browsers:
  Chrome: 150.0.7871.188
  Firefox: 145.0
  Safari: 26.5.2
npmPackages:
  @storybook/addon-mcp: 0.7.0 => 0.7.0
  @storybook/react-vite: 10.5.6 => 10.5.6
  storybook: 10.5.6 => 10.5.6

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions