How to write a generic so that the Result takes on the argument of another type supplied to the generic?
This is my example code.
import { Story } from '@storybook/react/types-6-0';
type TKeyAny = {
[key: string]: string; // | 'other args values here...';
};
// this fails
export const bindargs = <A extends TKeyAny, T extends Story<A>>(args: A, Template: T): T => {
const Comp = Template.bind({});
Comp.args = args;
return Comp;
};
export default bindargs;
This would work but its not specific to the arguments being passed into it, which is why I'd like a generic:
// This works but I'd like this instead to be in a generic
// export const bindargs = (args: TKeyAny, Template: Story<TKeyAny>): Story<TKeyAny> => {
// const Comp = Template.bind({});
// Comp.args = args;
// return Comp;
// };