Typings in Prisma client only work for the first model in the schema
See original GitHub issueBug description
Typings in Prisma client only work for the CRUD operations of the first model in node_modules/.prisma/client/index.d.ts
.
The typings for the first model in the schema work fine. i.e. prisma.user.createMany()
are auto completed with TS as I type. Hovering over createMany
brings me to the typed definition in prisma client index.d.ts
file.
The same is not true for all other models in the schema. i.e. prisma.property.createMany
stops auto completing after .property
and hovering over createMany
displays type any
.
If I go to node_modules/.prisma/client/index.d.ts
I see that Prisma.PropertyDelegate
has TS error of node_modules/.prisma/client/index".Prisma' has no exported member 'PropertyDelegate'
.
However, PropertyDelegate
DOES exist in the file. The code will run successfully but I get none of the benefits of using TS with Prisma client.
Why would all XDelegate
types after the first model appear to TS as not existing?
How to reproduce
I created a repo to reproduce the error
- Go to https://github.com/tgrander/prisma-heroku-ts
- Download repo
- Run
npm install
- Try to use prisma client for the post model, i.e.
prisma.post.createMany
- it will not work - Try to use prisma client for the user model, i.e.
prisma.user.createMany
- it will work because it is first model in schema
Expected behavior
I expect prisma client typings to work for all models - not just the first model in the schema.
Prisma information
Schema
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
email String @unique
id Int @id @default(autoincrement())
name String?
posts Post[]
}
model Post {
authorId Int?
content String?
id Int @id @default(autoincrement())
published Boolean @default(false)
title String
author User? @relation(fields: [authorId], references: [id])
}
Queries
Typings work and autocomplete for model
await prisma.user.deleteMany({
where: {
email: "jane@prisma.io",
},
});
Typings DO NOT work or autocomplete for model
await prisma.post.deleteMany({
where: {
author: {
email: "jane@prisma.io",
},
},
});
Environment & setup
- OS: Mac OS
- Database: PostgreSQL
- Node.js version: tried on 14.6 and 16.0
- Prisma version: prisma 2.22, @prisma/client 2.22
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:9 (6 by maintainers)
Top GitHub Comments
I am unable to reproduce this:
Can you please check the version of global typescript compiler installation if any that you have in your system and whether vscode is using that or not?
Ok, that is really weird. I know this sounds stupid, but have your fully restarted your VSCode and possibly computer? The language server sometimes is a bit stubborn…