Hey @marchaos :wave:, a user has opened this issue in Prisma, and after further investigation I pinned the performance issue to come from the MockDeep types provided here. We recently introduced meta types that are hidden under symbol. There's noting special about these types except that they can be very deep and recursive, but it's all objects/records in the end. I found that MockDeep caused/forced TypeScript to evaluate these types.
While this is not obvious, any intersection on a mapped type (eg. compute) itself will cause the mapped type to be resolved, otherwise TS would defer that for later (eg. when you access it). So MockDeep was forcing resolution on very huge and recursive types in the PrismaClient. This PR does not make things easier to read, but does make things more efficient, by forcing resolution within the mapped type itself. Also I had to re-intersect with the original type as well to preserve the full shape, including private props which mapped types remove.
With that, I was able to compile a huge PrismaClient like before we introduced this special type metadata on the symbol key.
Hey @marchaos :wave:, a user has opened this issue in Prisma, and after further investigation I pinned the performance issue to come from the
MockDeep
types provided here. We recently introduced meta types that are hidden undersymbol
. There's noting special about these types except that they can be very deep and recursive, but it's all objects/records in the end. I found thatMockDeep
caused/forced TypeScript to evaluate these types.While this is not obvious, any intersection on a mapped type (eg. compute) itself will cause the mapped type to be resolved, otherwise TS would defer that for later (eg. when you access it). So
MockDeep
was forcing resolution on very huge and recursive types in thePrismaClient
. This PR does not make things easier to read, but does make things more efficient, by forcing resolution within the mapped type itself. Also I had to re-intersect with the original type as well to preserve the full shape, including private props which mapped types remove.With that, I was able to compile a huge PrismaClient like before we introduced this special type metadata on the
symbol
key.