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]: type error for required props when reusing story definitions according to the docs #26968

Open
HosseinAgha opened this issue Apr 29, 2024 · 2 comments

Comments

@HosseinAgha
Copy link

HosseinAgha commented Apr 29, 2024

Describe the bug

When reusing story definitions according to the docs I get TypeScript type errors because the StoryObj helper type makes all arguments optional. Storybook should offer a workaround to use this pattern without any type errors.

To Reproduce

https://stackblitz.com/edit/github-yr2rcr?file=src%2Fstories%2FButton.stories.tsx

Check the Primary story.

System

System:
    OS: macOS 14.4.1
    CPU: (10) arm64 Apple M1 Pro
    Shell: 3.6.1 - /opt/homebrew/bin/fish
  Binaries:
    Node: 20.8.0 - ~/.local/share/nvm/v20.8.0/bin/node
    Yarn: 3.4.1 - ~/.local/share/nvm/v20.8.0/bin/yarn <----- active
    npm: 10.1.0 - ~/.local/share/nvm/v20.8.0/bin/npm
  Browsers:
    Chrome: 124.0.6367.91
    Edge: 115.0.1901.200
    Safari: 17.4.1
  npmPackages:
    eslint-plugin-storybook: ^0.6.13 => 0.6.15

Additional context

No response

@shilman
Copy link
Member

shilman commented May 25, 2024

@kasperpeulen any ideas?

@shilman shilman added the sev:S3 label May 25, 2024
@kasperpeulen
Copy link
Contributor

We should document this indeed cc @kylegach

In general, when reusing stories, it is best to use satisfies, this solves the type error @HosseinAgha

export const DefaultSubButton = {
  args: {
    message: '"Hello World!"',
  },
} satisfies StoryObj<typeof SubButton>;

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

No branches or pull requests

3 participants