storybookjs/storybook
[Bug]: StoriesEntry type does not allow for custom implementation with async function
已關閉
#21,524 建立於 2023年3月9日
bugcoregood first issuehas workaroundsev:S3typescript
倉庫指標
- 星標
- (89,909 顆星)
- PR 合併指標
- (平均合併 7天 22小時) (30 天內合併 184 個 PR)
描述
Describe the bug
In the storybook docs, there is an example where you can pass in an async function to stories to implement custom logic for loading stories. This works as expected, but if you are using typescript, it gives the error Type '() => Promise<string[]>' is not assignable to type 'StoriesEntry[]'.
To Reproduce
This config will produce the typescript error, although it is a valid way to construct a stories configuration, according to the docs.
import type { StorybookConfig } from '@storybook/react-webpack5';
const stories = Promise.resolve(['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'])
const config: StorybookConfig = {
stories: async () => [...await stories],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
],
framework: {
name: '@storybook/react-webpack5',
options: {},
},
docs: {
autodocs: 'tag',
},
};
export default config;
System
System:
OS: macOS 13.2.1
CPU: (8) arm64 Apple M1 Pro
Binaries:
Node: 18.14.2 - ~/.nvm/versions/node/v18.14.2/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v18.14.2/bin/yarn
npm: 9.5.0 - ~/.nvm/versions/node/v18.14.2/bin/npm
Browsers:
Chrome: 110.0.5481.177
Firefox: 109.0
Safari: 16.3
npmPackages:
@storybook/addon-essentials: ^7.0.0-beta.64 => 7.0.0-rc.0
@storybook/addon-interactions: ^7.0.0-beta.64 => 7.0.0-rc.0
@storybook/addon-links: ^7.0.0-beta.64 => 7.0.0-rc.0
@storybook/blocks: ^7.0.0-beta.64 => 7.0.0-rc.0
@storybook/react: ^7.0.0-beta.64 => 7.0.0-rc.0
@storybook/react-webpack5: ^7.0.0-beta.64 => 7.0.0-rc.0
@storybook/testing-library: ^0.0.14-next.1 => 0.0.14-next.1
Additional context
I am willing to submit a fix to the StoriesEntry type for this.