storybookjs / eslint-plugin-storybook

🎗Official ESLint plugin for Storybook
MIT License
248 stars 56 forks source link

[await-interactions] typescript warning: "'await' has no effect on the type of this expression." #45

Closed IanVS closed 2 years ago

IanVS commented 3 years ago

Describe the bug I'm not sure if this is necessarily a bug, but it's a bit unclear what the right thing to do is. When I await my userEvent calls, as directed by await-interactions, I get a typescript warning:

'await' has no effect on the type of this expression.

I guess that's because the typescript type from user-event is:

declare function click(element: Element, init?: MouseEventInit, { skipHover, clickCount }?: clickOptions): void;

So, it's unclear where the problem is, but there seems to be definite disagreement between this linting rule and typescript. :)

To Reproduce Steps to reproduce the behavior: In a typescript project, import userEvent from @storybook/testing-library, add an await, and see the typescript warning.

Expected behavior No warning to be shown

yannbf commented 3 years ago

Thanks for opening this issue @IanVS ! @ghengeveld I think this will interest you quite a bit

ghengeveld commented 2 years ago

The problem is in @storybook/testing-library. It needs to rewrite some type definitions to return T | Promise<T>.

ghengeveld commented 2 years ago

Opened an issue here: https://github.com/storybookjs/testing-library/issues/10