marchaos / jest-mock-extended

Type safe mocking extensions for Jest https://www.npmjs.com/package/jest-mock-extended
MIT License
810 stars 56 forks source link

Typescript error when using @jest/globals #115

Open dan2kx opened 1 year ago

dan2kx commented 1 year ago
node_modules/jest-mock-extended/lib/Mock.d.ts:13:61 - error TS2503: Cannot find namespace 'jest'.

13 export interface CalledWithMock<T, Y extends any[]> extends jest.Mock<T, Y> {
                                                               ~~~~

node_modules/jest-mock-extended/lib/Mock.d.ts:14:57 - error TS2503: Cannot find namespace 'jest'.

14     calledWith: (...args: Y | MatchersOrLiterals<Y>) => jest.Mock<T, Y>;
                                                           ~~~~

I think maybe jest needs to be imported from @jest/globals instead of using @types/jest which also throws an error if i install the latest version 29.5.0 to my project

node_modules/@jest/environment/build/index.d.ts:365:26 - error TS2430: Interface 'JestImportMeta' incorrectly extends interface 'ImportMeta'.
  Types of property 'jest' are incompatible.
    Type 'Jest' is missing the following properties from type 'typeof jest': runAllTimersAsync, runOnlyPendingTimersAsync, advanceTimersByTimeAsync, advanceTimersToNextTimerAsync

365 export declare interface JestImportMeta extends ImportMeta {