Quramy / jest-prisma

Jest environment for integrated testing with Prisma client
MIT License
266 stars 15 forks source link

jest-prisma 1.7.0 Type Definition of `global.jestPrisma` May Result in Unexpected `any` #111

Closed nbibler closed 11 months ago

nbibler commented 11 months ago

With the 1.7.0 release of @quramy/jest-prisma, there was a change to allow for customized jest prisma clients. This change included modification of the TypeScript type definition of jestPrisma to use a newly-created JestPrisma generic:

https://github.com/Quramy/jest-prisma/blob/ea717b88b7bd3a13b79443e946072317c2f70bc0/packages/jest-prisma/src/index.ts#L7-L9

That JestPrisma definition comes from a different package: @quramy/jest-prisma-core. The trouble here is that if you're upgrading an existing project, NPM has a terrible (incorrect, poor, dumb) habit of not updating sub-dependencies. This results in the 1.7.0 release of jest-prisma running against an old (in my case 1.5.0) release of jest-prisma-core. This results in the exported JestPrisma type not being a generic and causing the TypeScript system to infer jestPrisma as an any type.

In this case, the correct solution is likely to update the jest-prisma-core sub-dependency requirement to be ^1.7.0 rather than ^1.0.0 because it is no longer compatible below that.

nbibler commented 11 months ago

For application developers, the fix here is to force NPM to update the @juramy/jest-prisma-core dependency, which it often won't want to do. You may need to blow away things (package-lock.json, node_modules, etc.) to convince it to do its job.