Skip to content

Commit

Permalink
feat: improve shared types
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmckeb committed May 20, 2020
1 parent 3f4d4ef commit ee085e5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { StorybookConfig } from '@storybook/core/types';

module.exports = {
stories: [
// FIXME: Breaks e2e tests './intro.stories.mdx',
Expand Down Expand Up @@ -74,4 +76,4 @@ module.exports = {
extensions: [...(config.resolve.extensions || []), '.ts', '.tsx'],
},
}),
};
} as StorybookConfig;
18 changes: 15 additions & 3 deletions lib/core/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
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 {
/**
* Sets the addons you want to use with Storybook.
*
* @example `['@storybook/addon-essentials']`
*/
addons: string[];
addons?: string[];

This comment has been minimized.

Copy link
@shilman

shilman Nov 1, 2020

Member

Can also be { name: string, options: object }

/**
* Tells Storybook where to find stories.
*
Expand All @@ -21,12 +22,20 @@ export interface StorybookConfig {
* Controls how Storybook hanldes TypeScript files.
*/
typescript?: Partial<TypescriptOptions>;
/**
* Modify or return a custom Webpack config.
*/
webpackFinal?: (
config: Configuration,
options: StorybookOptions
) => Configuration | Promise<Configuration>;

This comment has been minimized.

Copy link
@arcanis

arcanis Nov 1, 2020

Contributor

Isn't the babel key missing (still documented here)?

This comment has been minimized.

Copy link
@shilman

shilman Nov 1, 2020

Member

Yup. PRs welcome!

}

/**
* The internal options object, used by Storybook frameworks and adddons.
*/
export interface StorybookOptions {
configType: 'DEVELOPMENT' | 'PRODUCTION';
typescriptOptions: TypescriptOptions;
}

Expand All @@ -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
*
Expand Down

0 comments on commit ee085e5

Please sign in to comment.