diff --git a/examples/official-storybook/main.js b/examples/official-storybook/main.ts similarity index 96% rename from examples/official-storybook/main.js rename to examples/official-storybook/main.ts index 6eea9d783a01..2c249eff765a 100644 --- a/examples/official-storybook/main.js +++ b/examples/official-storybook/main.ts @@ -1,3 +1,5 @@ +import type { StorybookConfig } from '@storybook/core/types'; + module.exports = { stories: [ // FIXME: Breaks e2e tests './intro.stories.mdx', @@ -74,4 +76,4 @@ module.exports = { extensions: [...(config.resolve.extensions || []), '.ts', '.tsx'], }, }), -}; +} as StorybookConfig; diff --git a/lib/core/types/index.ts b/lib/core/types/index.ts index 2edb41497374..eaaf4f72a67e 100644 --- a/lib/core/types/index.ts +++ b/lib/core/types/index.ts @@ -1,8 +1,9 @@ import type ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin'; import type LoaderOptions from 'react-docgen-typescript-loader/dist/LoaderOptions'; +import { Configuration } from 'webpack'; /** - * The interface for Storybook configuration in `main.js` files. + * The interface for Storybook configuration in `main.ts` files. */ export interface StorybookConfig { /** @@ -10,7 +11,7 @@ export interface StorybookConfig { * * @example `['@storybook/addon-essentials']` */ - addons: string[]; + addons?: string[]; /** * Tells Storybook where to find stories. * @@ -21,12 +22,20 @@ export interface StorybookConfig { * Controls how Storybook hanldes TypeScript files. */ typescript?: Partial; + /** + * Modify or return a custom Webpack config. + */ + webpackFinal?: ( + config: Configuration, + options: StorybookOptions + ) => Configuration | Promise; } /** * The internal options object, used by Storybook frameworks and adddons. */ export interface StorybookOptions { + configType: 'DEVELOPMENT' | 'PRODUCTION'; typescriptOptions: TypescriptOptions; } @@ -42,8 +51,11 @@ export interface TypescriptOptions { check: boolean; /** * Configures `fork-ts-checker-webpack-plugin` + * + * @default + * @see https://github.com/storybookjs/storybook/blob/next/lib/core/src/server/config/defaults.js#L4-L6 */ - checkOptions?: ForkTsCheckerWebpackPlugin['options']; + checkOptions: ForkTsCheckerWebpackPlugin['options']; /** * Sets the type of Docgen when working with React and TypeScript *