Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Interface 'JestImportMeta' incorrectly extends interface 'ImportMeta' in @jest/environment v29.7.0 #15302

Closed
Tracked by #1741
marekdedic opened this issue Sep 12, 2024 · 4 comments

Comments

@marekdedic
Copy link

Version

29.7.0

Steps to reproduce

  1. Install @jest/environment
  2. Enable exactOptionalPropertyTypes in your tsconfig
  3. Run TS

See skaut/shared-drive-mover#1741

Expected behavior

No error

Actual behavior

/home/user/project/node_modules/@jest/environment/build/index.d.ts:401:26
Error: Interface 'JestImportMeta' incorrectly extends interface 'ImportMeta'.
  The types of 'jest.doMock' are incompatible between these types.
    Type '<T = unknown>(moduleName: string, moduleFactory?: (() => T) | undefined, options?: { virtual?: boolean; } | undefined) => Jest' is not assignable to type '<T = unknown>(moduleName: string, factory?: (() => T) | undefined, options?: MockOptions | undefined) => typeof jest'.
      Types of parameters 'options' and 'options' are incompatible.
        Type 'MockOptions | undefined' is not assignable to type '{ virtual?: boolean; } | undefined'.
          Type 'MockOptions' is not assignable to type '{ virtual?: boolean; }' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
            Types of property 'virtual' are incompatible.
              Type 'boolean | undefined' is not assignable to type 'boolean'.
                Type 'undefined' is not assignable to type 'boolean'.

export declare interface JestImportMeta extends ImportMeta {
  jest: Jest;

Additional context

No response

Environment

System:
  OS: Linux 6.5 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
  CPU: (12) x64 12th Gen Intel(R) Core(TM) i7-1265U
Binaries:
  Node: 22.8.0 - /usr/bin/node
  Yarn: 1.22.21 - /usr/bin/yarn
  npm: 10.8.3 - /usr/bin/npm
  pnpm: 8.14.3 - /usr/bin/pnpm
npmPackages:
  jest: ^29.7.0 => 29.7.0
@mrazauskas
Copy link
Contributor

Could you check, if merging DefinitelyTyped/DefinitelyTyped#70464 would fix the problem?

@mrazauskas
Copy link
Contributor

The PR that I mentioned got merged. Can you check with the latest version of @types/jest?

@marekdedic
Copy link
Author

Hi @mrazauskas , thanks for the quick response (although it seems you were aware of this even before my report :)) - I can confirm that updating @types/jest fixes the issue for me, thanks!

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants