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

Commit

Permalink
export a few types
Browse files Browse the repository at this point in the history
  • Loading branch information
yannbf committed Dec 7, 2022
1 parent 3f814e8 commit ed4dcaf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import type { ComponentAnnotations, ProjectAnnotations, Store_CSFExports, StoryC
import { isExportStory } from '@storybook/csf';
import { deprecate } from '@storybook/client-logger';

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

export type { StoriesWithPartialProps, StoryFile } from './types'

// Some addons use the channel api to communicate between manager/preview, and this is a client only feature, therefore we must mock it.
addons.setChannel(mockChannel());

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

// This function should take this as input:
Expand Down
3 changes: 3 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ import type {
AnnotatedStoryFn,
Args,
PlayFunction, PlayFunctionContext,
Store_CSFExports,
StoryAnnotations,
} from '@storybook/types';
import type { ReactRenderer } from '@storybook/react';

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

export type StoryFile = Store_CSFExports<ReactRenderer, any>;

export type TestingStoryPlayContext<TArgs = Args> = Partial<PlayFunctionContext<ReactRenderer, TArgs>> & Pick<PlayFunctionContext, 'canvasElement'>

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

0 comments on commit ed4dcaf

Please sign in to comment.