Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 24, 2025

Closes #27129

What I did

Users with exactOptionalPropertyTypes: true could not pass undefined to optional type properties like argTypes.table.type.summary due to TypeScript's strict interpretation of prop?: string (allows omission only, not explicit undefined).

Updated public API type definitions to explicitly allow undefined:

  • PropSummaryValue (PropDef.ts, ArgsTable/types.ts): summary?: stringsummary?: string | undefined
  • InputType.table (story.ts, ArgsTable/types.ts): Added | undefined to type.summary, type.detail, defaultValue.summary, defaultValue.detail
  • ComponentManifest (core-common.ts): Added | undefined to description, import, summary, snippet fields

Users can now suppress automatic summary generation:

argTypes: {
  myArg: {
    table: {
      type: { summary: undefined },  // Now valid with exactOptionalPropertyTypes
    },
  },
}

Changes are backward compatible—users without exactOptionalPropertyTypes are unaffected.

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • unit tests
  • integration tests

Manual testing

Not required—changes are type-only. Verified with TypeScript compiler that:

  1. Types accept undefined with exactOptionalPropertyTypes: true
  2. All existing tests pass
  3. Type checking succeeds across all 82 packages

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook publish.yml --field pr=<PR_NUMBER>

Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug]: summary: undefined type issue</issue_title>
<issue_description>### Describe the bug

Hello,
We are using storybook with Typescript. When trying to upgrade to v8.0.10, we encountered a type issue when we want to suppress the automatic summary generated for Controls. Previously, we would make it null like so:

argTypes: {
  myArg: {
    table: {
      type: { summary: null },
    },
  },
},

With the change introduced at commit 3f7e1c2b84324ca24bc5bc968a6ab3245b11b757, null is no longer allowed. So we tried to use undefined instead. But since we use the stricter exactOptionalPropertyTypes: true configuration in our tsconfig.json, TypeScript raises the following error:

Type '{ summary: undefined; }' is not assignable to type '{ summary?: string; detail?: string; }' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
  Types of property 'summary' are incompatible.
    Type 'undefined' is not assignable to type 'string'.(2375)

Could you please change the type of summary to summary?: string | undefined so that we can keep our strict settings as well as disable the summary in controls ?

To Reproduce

Here is a link to reproduce: https://stackblitz.com/edit/github-wuwtca-dcgxst?file=src%2Fstories%2FButton.stories.ts

TypeScript raises an error in src/stories/Button.stories.ts, in argTypes property of meta.

System

Storybook Environment Info:

  System:
    OS: Linux 6.8 Fedora Linux 40 (Workstation Edition)
    CPU: (12) x64 12th Gen Intel(R) Core(TM) i7-1255U
    Shell: 5.2.26 - /bin/bash
  Binaries:
    Node: 20.11.1 - /nix/store/lajyj1j3bkzcpiqra4phhs810zxglcp6-build-tools-js/bin/node
    pnpm: 8.7.0 - /nix/store/lajyj1j3bkzcpiqra4phhs810zxglcp6-build-tools-js/bin/pnpm <----- active
  npmPackages:
    eslint-plugin-storybook: ^0.8.0 => 0.8.0

Additional context

No response</issue_description>

<agent_instructions>* [ ] Cherry pick commit df5ee7e from PR 32585 to ensure the contributor is credited

  • Locate all tsconfig files in code and add exactOptionalPropertyTypes: true to help surface issues
  • Run yarn task:check to identify types that need updating
  • Add | undefined to relevant places to ensure our own users can safely exactOptionalPropertyTypes: true when passing data to our APIs
  • Open a PR and wait for us to enable CI output so you get more feedback</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@shilman @Hyzual Any chance you can open a PR with the fix?

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Summary by CodeRabbit

  • Refactor
    • Tightened and broadened internal type definitions used by the docs and component metadata systems, clarifying optional fields may be explicitly undefined.
    • These are compile-time/type adjustments only — no runtime or user-facing behavior changes.

✏️ Tip: You can customize this high-level summary in your review settings.

@Sidnioulz
Copy link
Member

Also credit the author of commit 9b58ef1 on PR 27202

@nx-cloud
Copy link

nx-cloud bot commented Nov 24, 2025

View your CI Pipeline Execution ↗ for commit afd501d

Command Status Duration Result
nx run-many -t compile,check,knip,test,pretty-d... ✅ Succeeded 8m 32s View ↗

☁️ Nx Cloud last updated this comment at 2025-12-19 12:37:32 UTC

Copilot AI changed the title [WIP] Fix undefined summary type issue in storybook Fix: Support exactOptionalPropertyTypes for public API types Nov 24, 2025
Copilot AI requested a review from Sidnioulz November 24, 2025 15:40
@Sidnioulz Sidnioulz changed the title Fix: Support exactOptionalPropertyTypes for public API types TypeScript: Support exactOptionalPropertyTypes for public API types Nov 24, 2025
@Sidnioulz Sidnioulz added ci:normal maintenance User-facing maintenance tasks labels Dec 1, 2025
@Sidnioulz Sidnioulz marked this pull request as ready for review December 1, 2025 08:05
@Sidnioulz Sidnioulz force-pushed the copilot/fix-summary-type-issue branch from 1dbb8e2 to b7549fe Compare December 1, 2025 08:05
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 1, 2025

📝 Walkthrough

Walkthrough

Widened several optional string properties across TypeScript definitions to explicitly allow undefined (e.g., summary?: stringsummary?: string | undefined). Affected types include PropSummaryValue, InputType.table subproperties, and ComponentManifest nested fields. No runtime behavior changes.

Changes

Cohort / File(s) Summary
Arg Type Definitions
code/addons/docs/src/blocks/components/ArgsTable/types.ts, code/core/src/docs-tools/argTypes/docgen/PropDef.ts
PropSummaryValue fields summary and detail changed from string (optional) to `string
Input Type Definitions
code/core/src/csf/story.ts
InputType.table subproperties defaultValue and type now allow `summary?: string
Manifest Type Definitions
code/core/src/types/modules/core-common.ts
ComponentManifest fields description, import, summary and nested stories fields snippet, description, summary widened to `string

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Changes are a consistent, low-density type widening pattern across a few files.
  • Suggested focus areas:
    • Call sites where these properties are read and assumed to be non-undefined.
    • Public API surface types to ensure downstream packages expecting string handle undefined.
    • Any type re-exports or unions that might now accept undefined (possible downstream narrowing).

Possibly related PRs

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b7549fe and afd501d.

📒 Files selected for processing (1)
  • code/core/src/types/modules/core-common.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • code/core/src/types/modules/core-common.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: normal
  • GitHub Check: Core Unit Tests, windows-latest
  • GitHub Check: nx

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:normal maintenance User-facing maintenance tasks needs triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: summary: undefined type issue

4 participants