zenstack icon indicating copy to clipboard operation
zenstack copied to clipboard

Zenstack generate fails when trying to use tRPC plugin with strongly typed JSON

Open k-ahlawat opened this issue 1 month ago • 1 comments

Description and expected behavior When I add a strongly typed JSON column to my schema, and then run zenstack generate with the tRPC plugin enabled, it generates, but the generated code is unable to be compiled by tsc due to the following error:

The inferred type of 'createRouter' cannot be named without a reference to '../../../../node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected][email protected]/node_modules/.zenstack/logical-prisma-client/runtime/library.js'. This is likely not portable. A type annotation is necessary.

15 export default function createRouter() {
                           ~~~~~~~~~~~~

I'd expect it to just work, not sure where it's trying to reference the deep path from.

Environment (please complete the following information):

  • ZenStack version: 2.18.1
  • Prisma version: 6.6.0
  • Database type: postgresql

k-ahlawat avatar Nov 12 '25 07:11 k-ahlawat

Somewhat related: https://github.com/zenstackhq/zenstack/issues/560

k-ahlawat avatar Nov 12 '25 07:11 k-ahlawat

Hi @k-ahlawat , this error looks familiar but I couldn't reproduce it with a trpc project at hand (trpc 11 + pnpm). Do you have a sharable repro project? Thanks!

ymc9 avatar Nov 21 '25 18:11 ymc9

Unfortunately I don't have a standalone repro at the moment.

The whole thing started because tRPC (v11) can't properly infer Prisma.JsonValues on the client side due to the Serialize<T> type they have. I thought it'd be easier to solve by just strongly typing the columns. Related tRPC issue is here

k-ahlawat avatar Nov 21 '25 18:11 k-ahlawat