marchaos / jest-mock-extended

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

typescript 3.9.4 compilation issues #36

Closed regevbr closed 3 years ago

regevbr commented 4 years ago

After upgrading to typescript 3.94 I started getting the following errors:

 error TS2590: Expression produces a union type that is too complex to represent.

The issue doesn't happen for ts 3.8

To reproduce, install the latest typeorm package and typescript 3.9.4 and run:

import { Connection } from 'typeorm';
import * as typeorm from 'typeorm';
import { mock } from 'jest-mock-extended';

const typeOrmMock = mock<typeof typeorm>();
const connectionMock = mockDeep<Connection>();
typeOrmMock.createConnection.mockResolvedValue(connectionMock); //  error TS2590: Expression produces a union type that is too complex to represent.
marchaos commented 4 years ago

Will take a look

dmitrykologrivko commented 4 years ago

Same for me. Will be great if you can look at this issue. ts-ignore solve that problem as a temp solution.

JeremyLoy commented 4 years ago

also having this issue with TypeORM.

you can solve with a ts-ignore or by explicitly casting to unknown and then to your desired type

marchaos commented 3 years ago

Should be fixed now - mock() no longer uses recursive types