@storybook/testing-react type errors #62
Comments
Hey @rexkenley thanks for opening this issue! Could you provide an example of how your stories look like? Thanks! |
I am seeing something very similar with with 6.4. This story works (if I use import { Meta, ComponentStory } from "@storybook/react";
import { Logo } from ".";
export default {
component: Logo,
} as Meta;
const Template: ComponentStory<typeof Logo> = (args) => <Logo {...args} />;
export const Default = Template.bind({});
Default.args = {
width: 200,
fill: "#3C576B",
}; This story does not work (using import { ComponentStory, ComponentMeta } from "@storybook/react";
import { Logo } from ".";
export default {
component: Logo,
} as ComponentMeta<typeof Logo>;
const Template: ComponentStory<typeof Logo> = (args) => <Logo {...args} />;
export const Default = Template.bind({});
Default.args = {
width: 200,
fill: "#3C576B",
}; The test import looks like this: import { render, screen } from "@testing-library/react";
import { composeStories } from "@storybook/testing-react";
import * as stories from "./Logo.stories";
// TS2345
const { Default } = composeStories(stories); Full error when using
|
I'm experienced the same type errors when I upgraded sb to 6.4. My workaround was to use |
Hey @phenrique7 could you show the example of the component that fails? Is that component typed in any way or does it look like this? // no types at all, just auto-inferred JSX.Element
const MyComponent = () => <div>HelloWorld</div> |
@yannbf, I created a reproducible repo: https://github.com/phenrique7/storybook-testing-react-type-errors. Hope this can help. |
@yannbf, I didn't make any changes other than applying the composeStories. Here is the repo: https://github.com/rexkenley/rollupError |
Thanks @phenrique7 and @rexkenley for the repros, that helps me a ton!! have a great weekend! |
Hey everyone, I released a fix in v1.2.1 that should address this issue. The repros you provided were super helpful and I made sure to test in each one of them. @rexkenley I noticed a few things in your repo and I'll make a PR explaining the correct usage of this library! @phenrique7 I saw the easter egg there 😂 Muito obrigado! |
@yannbf Thank you so much to fixing this so quickly. I am looking forward to the correct usage link. |
No worries, thanks for using the library! I opened the PR at rexkenley/rollupError#1 |
Describe the bug
I am getting the following ts errors with my code while trying to use the new composeStories.
I was able to "fix" it by using casting, but I don't think this is right.
What should I do?
Storybook version: 6.4.4
The text was updated successfully, but these errors were encountered: