Skip to content
This repository was archived by the owner on Jan 31, 2024. It is now read-only.

Commit ed4dcaf

Browse files
committed
export a few types
1 parent 3f814e8 commit ed4dcaf

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ import type { ComponentAnnotations, ProjectAnnotations, Store_CSFExports, StoryC
44
import { isExportStory } from '@storybook/csf';
55
import { deprecate } from '@storybook/client-logger';
66

7-
import type { StoriesWithPartialProps, TestingStory, TestingStoryPlayContext } from './types';
7+
import type { StoriesWithPartialProps, StoryFile, TestingStory, TestingStoryPlayContext } from './types';
88
import { getStoryName, globalRender, isInvalidStory, objectEntries } from './utils';
99

10+
export type { StoriesWithPartialProps, StoryFile } from './types'
11+
1012
// Some addons use the channel api to communicate between manager/preview, and this is a client only feature, therefore we must mock it.
1113
addons.setChannel(mockChannel());
1214

@@ -204,7 +206,7 @@ export function composeStory<GenericArgs extends Args>(
204206
* @param storiesImport - e.g. (import * as stories from './Button.stories')
205207
* @param [globalConfig] - e.g. (import * as globalConfig from '../.storybook/preview') this can be applied automatically if you use `setGlobalConfig` in your setup files.
206208
*/
207-
export function composeStories<TModule extends Store_CSFExports<ReactRenderer, any>>(storiesImport: TModule, globalConfig?: ProjectAnnotations<ReactRenderer>) {
209+
export function composeStories<TModule extends StoryFile>(storiesImport: TModule, globalConfig?: ProjectAnnotations<ReactRenderer>) {
208210
const { default: meta, __esModule, __namedExportsOrder, ...stories } = storiesImport;
209211

210212
// This function should take this as input:

src/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@ import type {
22
AnnotatedStoryFn,
33
Args,
44
PlayFunction, PlayFunctionContext,
5+
Store_CSFExports,
56
StoryAnnotations,
67
} from '@storybook/types';
78
import type { ReactRenderer } from '@storybook/react';
89

910
export type TestingStory<TArgs = Args> = StoryAnnotations<ReactRenderer, TArgs>;
1011

12+
export type StoryFile = Store_CSFExports<ReactRenderer, any>;
13+
1114
export type TestingStoryPlayContext<TArgs = Args> = Partial<PlayFunctionContext<ReactRenderer, TArgs>> & Pick<PlayFunctionContext, 'canvasElement'>
1215

1316
export type StoryFn<TArgs = Args> = AnnotatedStoryFn<ReactRenderer, TArgs> & { play: PlayFunction<ReactRenderer, TArgs> }

0 commit comments

Comments
 (0)