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' #14097

Closed
unional opened this issue Apr 22, 2023 · 5 comments
Closed

Comments

@unional
Copy link
Contributor

unional commented Apr 22, 2023

Version

29.5.0

Steps to reproduce

This is similar to #13199 (comment)
but it reappears on 29.5.0

The error is:

../../node_modules/.pnpm/@jest+environment@29.5.0/node_modules/@jest/environment/build/index.d.ts(401,26): error TS2430: Interface 'JestImportMeta' incorrectly extends interface 'ImportMeta'.
  The types of 'jest.replaceProperty' are incompatible between these types.
    Type '<T extends object, K extends Exclude<keyof T, keyof { [K in keyof T as Required<T>[K] extends ClassLike ? K : never]: T[K]; } | keyof { [K in keyof T as Required<T>[K] extends FunctionLike ? K : never]: T[K]; }>, V extends T[K]>(object: T, propertyKey: K, value: V) => Replaced<...>' is not assignable to type '<T extends object, K extends keyof T>(obj: T, key: K, value: T[K]) => ReplaceProperty<T[K]>'.
      Types of parameters 'propertyKey' and 'key' are incompatible.
        Type 'K' is not assignable to type 'Exclude<keyof T, keyof { [K in keyof T as Required<T>[K] extends ClassLike ? K : never]: T[K]; } | keyof { [K in keyof T as Required<T>[K] extends FunctionLike ? K : never]: T[K]; }>'.
          Type 'keyof T' is not assignable to type 'Exclude<keyof T, keyof { [K in keyof T as Required<T>[K] extends ClassLike ? K : never]: T[K]; } | keyof { [K in keyof T as Required<T>[K] extends FunctionLike ? K : never]: T[K]; }>'.
            Type 'string | number | symbol' is not assignable to type 'Exclude<keyof T, keyof { [K in keyof T as Required<T>[K] extends ClassLike ? K : never]: T[K]; } | keyof { [K in keyof T as Required<T>[K] extends FunctionLike ? K : never]: T[K]; }>'.
              Type 'string' is not assignable to type 'Exclude<keyof T, keyof { [K in keyof T as Required<T>[K] extends ClassLike ? K : never]: T[K]; } | keyof { [K in keyof T as Required<T>[K] extends FunctionLike ? K : never]: T[K]; }>'

Should be able to repro by installing both jest and @types/jest.

Expected behavior

no err

Actual behavior

error

Additional context

No response

Environment

npx envinfo --preset jest

  System:
    OS: Linux 5.15 Ubuntu 20.04.5 LTS (Focal Fossa)
    CPU: (16) x64 AMD Ryzen 7 5800X 8-Core Processor
  Binaries:
    Node: 16.15.1 - ~/.nvm/versions/node/v16.15.1/bin/node
    npm: 8.11.0 - ~/.nvm/versions/node/v16.15.1/bin/npm
  npmPackages:
    jest: ^29.5.0 => 29.5.0
unional added a commit to repobuddy/repobuddy that referenced this issue Apr 22, 2023
remove @types/jest from @repobuddy/jest due to:
jestjs/jest#14097

Add `with-t` test case.

There was a failure in `async-fp`,
but it is working after upgrading to jest 29.5.0

Adding the test case here for reference.
@mrazauskas
Copy link
Contributor

There was a problem with @types/jest v29.5.0, but v29.5.1 should be working fine. Fixed relatively recently (according to NPM it was publish 4 days ago). Could you check which version caused this problem for you?

@unional
Copy link
Contributor Author

unional commented Apr 23, 2023

This is tested with @types/jest 29.5.1

Here is a repo from the code that I was working on.
https://github.com/repobuddy/jest/tree/jest-14097

Run:

  • pnpm i
  • pnpm jest build

@mrazauskas
Copy link
Contributor

mrazauskas commented Apr 23, 2023

Got it. This is fixed already in #14008, only not yet released. So all should be working fine with the next version of Jest.

@SimenB
Copy link
Member

SimenB commented Apr 23, 2023

Let's close, then 👍

@github-actions
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 May 24, 2023
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

3 participants