minor improvement in StorybookConfig type

This commit is contained in:
Norbert de Langen 2022-12-08 16:48:05 +01:00
parent d67e466939
commit 77f0d4fede
No known key found for this signature in database
GPG Key ID: FD0E78AF9A837762

View File

@ -341,7 +341,7 @@ export interface StorybookConfig {
/**
* References external Storybooks
*/
refs?: CoreCommon_StorybookRefs | ((config: any, options: Options) => CoreCommon_StorybookRefs);
refs?: PresetValue<CoreCommon_StorybookRefs>;
/**
* Modify or return babel config.
@ -364,17 +364,17 @@ export interface StorybookConfig {
*
* @deprecated use `previewAnnotations` or `/preview.js` file instead
*/
config?: (entries: Entry[], options: Options) => Entry[];
config?: PresetValue<Entry[]>;
/**
* Add additional scripts to run in the preview a la `.storybook/preview.js`
*/
previewAnnotations?: (entries: Entry[], options: Options) => Entry[];
previewAnnotations?: PresetValue<Entry[]>;
/**
* Process CSF files for the story index.
*/
storyIndexers?: (indexers: StoryIndexer[], options: Options) => StoryIndexer[];
storyIndexers?: PresetValue<StoryIndexer[]>;
/**
* Docs related features in index generation
@ -386,11 +386,13 @@ export interface StorybookConfig {
* The previewHead and previewBody functions accept a string,
* which is the existing head/body, and return a modified string.
*/
previewHead?: (head: string, options: Options) => string;
previewHead?: PresetValue<string>;
previewBody?: (body: string, options: Options) => string;
previewBody?: PresetValue<string>;
}
export type PresetValue<T> = T | ((config: T, options: Options) => T | Promise<T>);
export type PresetProperty<K, TStorybookConfig = StorybookConfig> =
| TStorybookConfig[K extends keyof TStorybookConfig ? K : never]
| PresetPropertyFn<K, TStorybookConfig>;