You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 16, 2024. It is now read-only.
Using expect, as exported by @storybook/jest, triggers failures in the @typescript-eslint/no-unsafe-member-access and @typescript-eslint/no-unsafe-call rules. Using the @storybook/expect version does not.
Confusingly, if I create a local copy of all of the @storybook/jest and call that version instead, this works correctly.
Steps to reproduce the behavior
Ensure project has eslint running, using plugin:@typescript-eslint/recommended
Create a new story, and in its play function, call expect from @storybook/expect.
Note that no eslint errors are shown.
Replace import expect from '@storybook/expect' with import { expect } from '@storybook/jest'
Not that expect calls now show eslint errors for @typescript-eslint/no-unsafe-member-access and @typescript-eslint/no-unsafe-call
Copy all of @storybook/jest's code into a local jest.ts file, and replace import { expect } from '@storybook/jest' with import { expect } from './jest'
Note that no eslint errors are shown.
Expected behavior
None of the three cases described above should show these eslint errors.
The exported type definitions for @storybook/jest are:
import * as mock from 'jest-mock';
export declare const jest: typeof mock;
export declare const expect: import("expect/build/types").Expect<import("expect/build/types").MatcherState>;
Eslint (as well as VSCode's intellisense) seems to interpret the type of this expect as any.
It should instead have the same type as the expect exported from @storybook/expect (and it does... but only if I copy the @storybook/jest code locally).
Screenshots and/or logs
For this line: expect(canvas.queryByText('Message')).not.toBeNull();
We get
Line 40:5: Unsafe member access .not on an `any` value @typescript-eslint/no-unsafe-member-access
Line 40:5: Unsafe call of an `any` typed value @typescript-eslint/no-unsafe-call
Line 40:5: Unsafe call of an `any` typed value @typescript-eslint/no-unsafe-call
Environment
OS: Windows
Node.js version: v16.13.0
NPM version: 8.1.0
Browser (if applicable): N/A
Browser version (if applicable): N/A
Device (if applicable): N/A
Additional context
Possibly caused by the esm compile target being ES5? I'll try and check this.
The text was updated successfully, but these errors were encountered:
Describe the bug
Using
expect
, as exported by@storybook/jest
, triggers failures in the@typescript-eslint/no-unsafe-member-access
and@typescript-eslint/no-unsafe-call
rules. Using the@storybook/expect
version does not.Confusingly, if I create a local copy of all of the
@storybook/jest
and call that version instead, this works correctly.Steps to reproduce the behavior
plugin:@typescript-eslint/recommended
play
function, callexpect
from@storybook/expect
.import expect from '@storybook/expect'
withimport { expect } from '@storybook/jest'
expect
calls now show eslint errors for@typescript-eslint/no-unsafe-member-access
and@typescript-eslint/no-unsafe-call
@storybook/jest
's code into a localjest.ts
file, and replaceimport { expect } from '@storybook/jest'
withimport { expect } from './jest'
Expected behavior
None of the three cases described above should show these eslint errors.
The exported type definitions for
@storybook/jest
are:Eslint (as well as VSCode's intellisense) seems to interpret the type of this
expect
asany
.It should instead have the same type as the
expect
exported from@storybook/expect
(and it does... but only if I copy the@storybook/jest
code locally).Screenshots and/or logs
For this line:
expect(canvas.queryByText('Message')).not.toBeNull();
We get
Environment
Additional context
Possibly caused by the esm compile target being ES5? I'll try and check this.
The text was updated successfully, but these errors were encountered: