Skip to content

Commit

Permalink
Allowing ArgsStoryFn's Args type to be more specific.
Browse files Browse the repository at this point in the history
  • Loading branch information
kahirokunn committed Aug 13, 2020
1 parent 78aba40 commit e7d7c9c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/addons/src/types.ts
Expand Up @@ -92,8 +92,13 @@ export interface OptionsParameter extends Object {
export type StoryGetter = (context: StoryContext) => any;

export type LegacyStoryFn<ReturnType = unknown> = (p?: StoryContext) => ReturnType;
export type ArgsStoryFn<ReturnType = unknown> = (a?: Args, p?: StoryContext) => ReturnType;
export type StoryFn<ReturnType = unknown> = LegacyStoryFn<ReturnType> | ArgsStoryFn<ReturnType>;
export type ArgsStoryFn<ReturnType = unknown, ArgsType extends Args = Args> = (
a?: ArgsType,
p?: StoryContext
) => ReturnType;
export type StoryFn<ReturnType = unknown, ArgsType = Args> =
| LegacyStoryFn<ReturnType>
| ArgsStoryFn<ReturnType, ArgsType>;

export type StoryWrapper = (
getStory: StoryGetter,
Expand Down

0 comments on commit e7d7c9c

Please sign in to comment.