Open ChoSeoHwan opened 8 months ago
Hello, we're using this library within Typescript, and we found that when using prisma.$primary()
as specified in this blog post, we encounter the following error mesage:
Property '$primary' does not exist on type 'PrismaClient<PrismaClientOptions, never, DefaultArgs> | DynamicClientExtensionThis<TypeMap<InternalArgs & { result: {}; model: {}; query: {}; client: { ...; }; }>, TypeMapCb, { ...; }>'.
Property '$primary' does not exist on type 'PrismaClient<PrismaClientOptions, never, DefaultArgs>'.ts(2339)
By silencing the Typescript error with a // @ts-ignore
comment, the client works as expected. Is our problem related? Is there anything we can do to solve this type issue?
Versions:
"@prisma/client": "^5.7.0",
"@prisma/extension-read-replicas": "^0.3.0",
Reproduce
reproduce package : https://github.com/ChoSeoHwan/prisma-extension-read-replicas-bug-0
git clone https://github.com/ChoSeoHwan/prisma-extension-read-replicas-bug-0.git
yarn install
yarn prisma:generate
yarn build
Error
Property '$primary' does not exist on type 'DynamicClientExtensionThis<TypeMap<InternalArgs & { result: {}; model: {}; query: {}; client: {}; }>, TypeMapCb, { result: {}; model: {}; query: {}; client: {}; }>'.
Solutions
This occurs when moduleResolution in tsconfig is NodeNext. The project is an esm module (type:module in package.json), Accordingly, the
.js
extension must be added when importing.When checking dist/index.d.ts built from the current @prisma/extension-read-replicas library, When importing, it is confirmed that there is no
.js
extension.For compatibility with multiple projects, you must add the .js extension.