prisma: `$extends` TS error: "Inferred type of this node exceeds the maximum length the compiler will serialize" with `"declaration": true` in `tsconfig`

The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed.

This error also showed up in another project.

Screenshot from 2022-11-30 12-46-59

Source file. To reproduce, check out main, and upgrade to Prisma 4.7

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 3
  • Comments: 21 (12 by maintainers)

Most upvoted comments

Thanks for your reproduction @adamhamlin, I can confirm that it will be fixed.

Hi @mshd and thank you for your report! This error is related to failure to emit declarations — notice that despite the error, if you hover the mouse over the variable in your editor, you can still see that TypeScript infers a type. Adding

"compilerOptions": {
  "declaration": false
}

to tsconfig.json prevents the issue, so this is the workaround for now. We will work on investigating and fixing the root cause, as of course the functionality should work regardless of this compiler option. Thanks for bringing this to our attention.

Hello, unfortunately we have a similar problem. Prisma client $extension with $allModels and $allOperations results in a JavaScript heap out of memory error. But this only happens when declarations is set to true. If declarations are set to false, it works. Using TypeScript 5.1.6.

Thanks for your effort and best regards

At the moment, my minimal reproduction is the following. Could you confirm this also fails on your end?

@millsp yes, confirming the same issue using your example

@adamhamlin You are correct, or at least from my first investigation performance issues are arising with how we deal with intersections, which are inefficient, on $allModels. Currently, I consider your issue to be 100% related to what’s been reported at https://github.com/prisma/prisma/issues/19999, for some it will be a length serialization error, for others it will be memory exhaustion (I’ve seen both while investigating the issue).