Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 24, 2025

Closes #XXXXX

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.

@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 1dbb8e2

Command Status Duration Result
nx run-many -t build --parallel=3 ✅ Succeeded 44s View ↗

☁️ Nx Cloud last updated this comment at 2025-11-24 15:57:12 UTC

@github-actions
Copy link
Contributor

github-actions bot commented Nov 24, 2025

Fails
🚫

PR is not labeled with one of: ["cleanup","BREAKING CHANGE","feature request","bug","documentation","maintenance","build","dependencies"]

🚫

PR is not labeled with one of: ["ci:normal","ci:merged","ci:daily","ci:docs"]

Generated by 🚫 dangerJS against 1dbb8e2

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
Copilot finished work on behalf of 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: summary: undefined type issue

2 participants