Skip to content

Commit

Permalink
feat(types): infer defaultValue of argtype based on arg
Browse files Browse the repository at this point in the history
  • Loading branch information
yannbf committed Aug 9, 2021
1 parent a8a41dc commit bfc6632
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/addons/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,20 @@ export interface Args {
[key: string]: any;
}

export interface ArgType {
export interface ArgType<Arg = unknown> {
name?: string;
description?: string;
defaultValue?: any;
defaultValue?: Arg;
[key: string]: any;
}

export type ArgTypes<Args = Record<string, any>> = {
[key in keyof Partial<Args>]: ArgType;
};
export type ArgTypes<GenericArgs = Args> = {
[key in keyof Partial<GenericArgs>]: ArgType<GenericArgs[key]>;
} &
{
// for custom defined args
[key in string]: ArgType<unknown>;
};

export interface StoryIdentifier {
id: StoryId;
Expand Down

0 comments on commit bfc6632

Please sign in to comment.