Skip to content

[Bug]: StoriesEntry type does not allow for custom implementation with async function #21524

Description

@imccausl

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.

Activity

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

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions