P
Prisma5mo ago
David

`prisma-client` generator in compiled workspace package

Running into this error:
The inferred type of 'foo' cannot be named without a reference to '../../../node_modules/@mrb/mysql/dist/generated/internal/prismaNamespace'. This is likely not portable. A type annotation is necessary.
The inferred type of 'foo' cannot be named without a reference to '../../../node_modules/@mrb/mysql/dist/generated/internal/prismaNamespace'. This is likely not portable. A type annotation is necessary.
I know you can get rid of th error by setting declaration to false, but that is not an option for me. What is the best way to go about this?
11 Replies
Prisma AI Help
Prisma AI Help5mo ago
You selected the carefully hand-crafted route. A dev artisan will respond soon. Meanwhile, the #ask-ai channel awaits if you're curious!
David
DavidOP5mo ago
Any ideas about this?
Nurul
Nurul5mo ago
Can you share your setup so that I can try to reproduce and find a solution? A minimal reproduction will be helpful.
David
DavidOP5mo ago
Yes, let me get a repro set up
David
DavidOP5mo ago
https://github.com/dbrxnds/prisma-internal-package-repro Here you go. If you clone it and then run pnpn dev you will see the issue occur in the nested-package/index.ts file.
GitHub
GitHub - dbrxnds/prisma-internal-package-repro
Contribute to dbrxnds/prisma-internal-package-repro development by creating an account on GitHub.
David
DavidOP5mo ago
Any idea? @Nurul
Adrian
Adrian5mo ago
I tried to do this as well. I ended up using package.json imports to use it:
"imports": {
"#my-pkg-name/prisma/*": "../prisma/src/*"
},
"imports": {
"#my-pkg-name/prisma/*": "../prisma/src/*"
},
For the actual Prisma pkg I generated the ouptut into the apps folder, and used npm pkg set name=@my-pkg-name/prisma-client to change the package.json name field
David
DavidOP5mo ago
Im not sure I follow. Do you add this to the package that consumes the Prisma package where the error occures?
Adrian
Adrian5mo ago
To the package that consumes it. It acts like a normal import doing it like that and Typescript is happy
David
DavidOP5mo ago
Interesting, will give that a shot. Thanks! Kind of breaks the workspace system though I imagine
Adrian
Adrian5mo ago
It does a little, but it was the best option I could find. My particular issue was I have a .$extends and the typescript was being changed from a generic to explicit definitions, which broke the logic for some reason. So I found switching to this method a way to get round that

Did you find this page helpful?