Skip to content

bug: Unable to infer Prisma.JsonValue properly, TypeScript says Type instantiation is excessively deep and possibly infinite #6997

@k-ahlawat

Description

@k-ahlawat

Provide environment information

  System:
    OS: macOS 15.6.1
    CPU: (12) arm64 Apple M4 Pro
    Memory: 348.33 MB / 24.00 GB
    Shell: 4.1.2 - /opt/homebrew/bin/fish
  Binaries:
    Node: 24.0.1 - /Users/karan/.local/share/mise/installs/node/24.0.1/bin/node
    npm: 11.3.0 - /Users/karan/.local/share/mise/installs/node/24.0.1/bin/npm
    pnpm: 10.16.1 - /Users/karan/.local/share/mise/installs/node/24.0.1/bin/pnpm
    bun: 1.2.21 - /Users/karan/.local/share/mise/installs/bun/1.2.21/bin/bun
  Browsers:
    Chrome: 142.0.7444.60
    Safari: 18.6
  npmPackages:
    typescript: ~5.8.3 => 5.8.3

Describe the bug

We're using ZenStack's TRPC plugin to automatically generate TRPC router for Prisma models. Some of our models have JSON fields, which Prisma types as Prisma.JsonValue.

The issue we seem to be facing is, over the network boundary, when TRPC tries to infer the return types of these auto-generated procedures on the client side, it can't correctly infer the Prisma.JsonValue, as it doesn't Serialize well, and since it's recursive, it gets infinitely deep.

Link to reproduction

N/A

To reproduce

  1. Write a procedure that returns an object of type Prisma.JsonValue.
  2. Try to use the router type to create a client.
  3. Call the procedure on the client, accessing the return value. TypeScript is unable to properly type the object, and we get the above mentioned error.

Additional information

N/A

👨‍👧‍👦 Contributing

  • 🙋‍♂️ Yes, I'd be down to file a PR fixing this bug!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions