Typescript errors when using template.bind() with Story type
See original GitHub issueDescribe the bug
New typings in this commit cause typescript errors when using bind() as Story can now be a function or an object
TS2339: Property ‘bind’ does not exist on type ‘Story<any>’. Property ‘bind’ does not exist on type ‘BaseStoryObject<any, StoryFnAngularReturnType> & Annotations<any, StoryFnAngularReturnType>’.
export declare type BaseStory<Args, StoryFnReturnType> = BaseStoryFn<Args, StoryFnReturnType> | BaseStoryObject<Args, StoryFnReturnType>;
When I remove the BaseStoryObject the error goes away
export declare type BaseStory<Args, StoryFnReturnType> = BaseStoryFn<Args, StoryFnReturnType>;
To Reproduce
My template is in a helper class like so.
class Utils {
template: Story = () => ({});
}
let utils = new Utils();
utils.bar.bind({});
Issue screenshot
What is strange is that this only happens when my template is in a class, This code below does not have the error
const baz: Story = () => ({});
baz.bind({})
System
Angular 12.1.4
Environment Info:
System: OS: macOS 11.5 CPU: (12) x64 Intel® Core™ i7-9750H CPU @ 2.60GHz Binaries: Node: 14.15.5 - ~/.nvm/versions/node/v14.15.5/bin/node Yarn: 1.22.10 - ~/.nvm/versions/node/v14.15.5/bin/yarn npm: 6.14.11 - ~/.nvm/versions/node/v14.15.5/bin/npm Browsers: Chrome: 92.0.4515.107 Edge: 92.0.902.55 Firefox: 89.0.2 Safari: 14.1.2 npmPackages: @storybook/addon-a11y: ^6.4.0-alpha.22 => 6.4.0-alpha.22 @storybook/addon-actions: ^6.4.0-alpha.22 => 6.4.0-alpha.22 @storybook/addon-essentials: ^6.4.0-alpha.22 => 6.4.0-alpha.22 @storybook/addon-links: ^6.4.0-alpha.22 => 6.4.0-alpha.22 @storybook/angular: ^6.4.0-alpha.22 => 6.4.0-alpha.22 @storybook/builder-webpack5: ^6.4.0-alpha.22 => 6.4.0-alpha.22 @storybook/manager-webpack5: ^6.4.0-alpha.22 => 6.4.0-alpha.22
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (8 by maintainers)
Thanks for the update. I’ve taken a look at CSF3 and I’m happy to manually migrate. CSF3 gets rid of a lot of repetition that will probably remove the need for my utility class.
@yannbf can you please take a look at this one?