You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I'd like if (none const) enums are working out of the box with select(...) knobs, as this is "just" a typing issue.
Describe the solution you'd like
The fix I currently use is a custom module declaration in my project.
I suppose the additional type could be added as an overload of the select() function
/** * the import is here to make the file a module * else it would replace the typedefs, instead of extending them * which leads to missing types for everything, but select with enums */import'@storybook/addon-knobs';declare module '@storybook/addon-knobs'{/** * @typeparam EnumT any none const enum, e.g ButtonVariant * @typeparam ResultT one (and any) of the enum values, e.g ButtonVariant.Primary * * @example * enum ButtonVariant { * Primary = 'primary', * Secondary = 'secondary' * } * const selectKnob: ButtonVariant = select('variant', ButtonVariant, ButtonVariant.Primary); */exportfunctionselect<EnumTextends{},ResultT=EnumT[keyofEnumT]>(name: string,options: EnumT,value: ResultT,groupId?: string): ResultT;}
Describe alternatives you've considered
writing a function that creates a select knob out of an enum, its default value and name
Are you able to assist bring the feature to reality?
I can create a PullRequest, suppose I'd find time on the weekend.
If this is a wanted feature.
Additional context
the TS Error I get currently:
TS2345: Argument of type 'typeof ButtonVariant' is not assignable to parameter of type 'readonly ButtonVariant.primary[]'. Type 'typeof ButtonVariant' is missing the following properties from type 'readonly ButtonVariant.primary[]': length, concat, join, slice, and 16 more
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
I'd like if (none const) enums are working out of the box with
select(...)
knobs, as this is "just" a typing issue.Here is an example of what I'd like to do:
Describe the solution you'd like
The fix I currently use is a custom module declaration in my project.
I suppose the additional type could be added as an overload of the
select()
functionDescribe alternatives you've considered
Are you able to assist bring the feature to reality?
I can create a PullRequest, suppose I'd find time on the weekend.
If this is a wanted feature.
Additional context
the TS Error I get currently:
The text was updated successfully, but these errors were encountered: