Closed
Description
Bug or support request summary
The select
knob's type is incorrect, as it does not support using an array of option objects, as per the example in the readme file.
const label = 'Dogs';
const arrayOfObjects = [
{
label: 'Sparky',
dogParent: 'Matthew',
location: 'Austin',
},
{
label: 'Juniper',
dogParent: 'Joshua',
location: 'Austin',
},
];
const defaultValue = arrayOfObjects[0];
const groupId = 'GROUP-ID3';
const value = select(label, options, defaultValue, groupId);
Side note: the example needs to be fixed
options
needs to be changed toarrayOfObjects
.
Typescript complains with the following error:
Argument of type '{ label: string; dogParent: string; location: string; }[]' is not assignable to parameter of type 'SelectTypeOptionsProp<SelectTypeKnobValue>'.
Type '{ label: string; dogParent: string; location: string; }[]' is not assignable to type 'ReactText[]'.
Type '{ label: string; dogParent: string; location: string; }' is not assignable to type 'ReactText'.
Type '{ label: string; dogParent: string; location: string; }' is not assignable to type 'number'.ts(2345)
Steps to reproduce
Try the above example.
Please specify which version of Storybook and optionally any affected addons that you're running
- @storybook/react 5.3.10 (as 5.3.11 has an open issue)
- @storybook/addon-knob 5.3.11
Affected platforms
- VSCode with Typescript v3.7.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment