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]: addon-actions action handler not assignable to async callback props #23731

Open
eliasm307 opened this issue Aug 5, 2023 · 1 comment

Comments

@eliasm307
Copy link

Describe the bug

When the action function is used for an async callback property a type error occurs e.g.

image

To Reproduce

Stackblitz reproduction: https://stackblitz.com/edit/github-u61rhv?file=stories%2FButton.stories.ts

System

Environment Info:

  System:
    OS: Windows 10 10.0.22621
    CPU: (8) x64 Intel(R) Core(TM) i5-10300H CPU @ 2.50GHz
  Binaries:
    Node: 18.12.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 3.2.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 8.19.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 115.0.5790.110
    Edge: Spartan (44.22621.1992.0), Chromium (115.0.1901.188)
  npmPackages:
    @storybook/addon-essentials: ^7.2.0 => 7.2.0 
    @storybook/addon-interactions: ^7.2.0 => 7.2.0 
    @storybook/addon-links: ^7.2.0 => 7.2.0
    @storybook/blocks: ^7.2.0 => 7.2.0
    @storybook/nextjs: ^7.2.0 => 7.2.0
    @storybook/react: ^7.2.0 => 7.2.0
    @storybook/testing-library: ^0.2.0 => 0.2.0

Additional context

I think its a case of setting the return type for the HandlerFunction here https://github.com/storybookjs/storybook/blob/next/code/addons/actions/src/models/HandlerFunction.ts to any (unknown or
void|Promise<void> doesnt work)

@parkerholladay
Copy link

I had a similar issue, and, in case it is helpful, the following is an ok workaround:

const meta = {
  args: {
    asyncHandler: async (...args) => {
      action('async-handler')(args)
    },
  },
  component: Component,
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

3 participants