Skip to content

Commit

Permalink
apply @BeInLife 's comment about generic type for StoryPropertyOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
ndelangen committed Jan 30, 2020
1 parent e329b85 commit a65b41a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ export interface StoryPropertyButton extends StoryPropertyBase<void> {
onClick?: (prop: StoryPropertyButton) => void;
}

export type OptionsValueType =
export type OptionsValueType<T = unknown> =
| T
| string
| number
| string[]
Expand All @@ -232,7 +233,7 @@ export type OptionsValueType =
/**
* value/label pairs or array of OptionsValueType
*/
export type OptionsListType = { [key: string]: string } | OptionsValueType[];
export type OptionsListType<T = unknown> = { [key: string]: T } | OptionsValueType<T>[];

/**
* list of options can be
Expand All @@ -241,12 +242,12 @@ export type OptionsListType = { [key: string]: string } | OptionsValueType[];
* 3. array of key-value pair objects
*/

export interface StoryPropertyOptions extends StoryPropertyBase<OptionsValueType> {
export interface StoryPropertyOptions<T = unknown> extends StoryPropertyBase<OptionsValueType<T>> {
type: PropertyTypes.OPTIONS;

options: OptionsListType;
options: OptionsListType<T>;
/**
* how to render slecting the options:
* how to render selecting the options:
* default is 'select'
*/

Expand Down

0 comments on commit a65b41a

Please sign in to comment.