Having some difficulties implementing a reduce function with TypeScript - struggling with types and return value. Facing issues with omitting controls from Storybook, causing two TypeScript errors indicated in the code marked ** ERROR **
Seeking advice on the correct solution and how to eliminate these error messages?
const controlsToOmit: string[] = [
'connectedLeft',
'connectedRight',
];
interface Props {
accumulator: {
[key: string]: {
table: {
disable: true;
};
};
};
value: string;
}
const controlsToOmitArgTypes = controlsToOmit.reduce<Props>(
(accumulator, value) => ({
...accumulator,
[value]: {
table: {
disable: true,
},
},
}),
{} ** Argument of type '{}' is not assignable to parameter of type 'Props' **
);
export default {
title: 'Components/Buttons/ButtonMeta',
component: ButtonMetaComponent,
argTypes: {
...controlsToOmitArgTypes, ** Spread types may only be created from object types. **
},
};
The controlsToOmitArgTypes
produces the following object
{
"connectedLeft": {
"table": {
"disable": true
}
},
"connectedRight": {
"table": {
"disable": true
}
},
}