storybookjs / testing-react

Testing utilities that allow you to reuse your Storybook stories in your React unit tests!
MIT License
588 stars 24 forks source link

JSX element type does not have any construct or call signatures #80

Closed do-kevin closed 2 years ago

do-kevin commented 2 years ago

Hi, sorry if this is a newbie question. I'm new to Storybook, Testing Library, and TypeScript. I'm trying to avoid using any as much as possible and am wondering why I am getting this typing error for my component story.

Also, would you be open to showing discussions on this repository? I don't believe my issue is suited as a bug report and should be in discussions instead. Thanks!

Screenshot_1

yannbf commented 2 years ago

Hey @do-kevin thanks for using this library! And don't worry about opening issues.

I see that your <Default /> component is of type unknown. Do you have either of these options in your tsconfig?

// tsconfig.json
{
  "compilerOptions": {
    // ...
    "strict": true, // You need either this option
    "strictBindCallApply": true // or this option
    // ...
  }
  // ...
}

It's mentioned in the Typescript section of the README.

This config will make Typescript properly infer the types of stories that use Template.bind({}) which should also resolve the type in your component. If you already do that and the problem is still there, please let me know! I might need a reproduction repo to check it out

do-kevin commented 2 years ago

I used strict: true and it worked. Thanks!