Quramy / jest-prisma

Jest environment for integrated testing with Prisma client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

nbibler opened this issue · comments

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:

declare global {
var jestPrisma: JestPrisma<PrismaClient>;
}

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.

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.