Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: summary: undefined type issue #27129

Open
Hyzual opened this issue May 14, 2024 · 3 comments · May be fixed by #27202
Open

[Bug]: summary: undefined type issue #27129

Hyzual opened this issue May 14, 2024 · 3 comments · May be fixed by #27202

Comments

@Hyzual
Copy link

Hyzual commented May 14, 2024

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

@shilman
Copy link
Member

shilman commented May 19, 2024

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

@shilman shilman added the sev:S4 label May 19, 2024
@Hyzual
Copy link
Author

Hyzual commented May 19, 2024

OK, I'll open one next week👌

@angad-sethi angad-sethi linked a pull request May 20, 2024 that will close this issue
8 tasks
@angad-sethi
Copy link

G'day folks, I've jumped the gun and created a PR for this here.
@Hyzual, please lmk if this fixes your issue!

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

Successfully merging a pull request may close this issue.

3 participants