-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Prisma Client is incompatible with TypeScript 4.8 #15041
Copy link
Copy link
Closed
Labels
bug/2-confirmedBug has been reproduced and confirmed.Bug has been reproduced and confirmed.kind/bugA reported bug.A reported bug.tech/typescriptIssue for tech TypeScript.Issue for tech TypeScript.topic: prisma-client
Milestone
Description
Bug description
When trying to build prisma-using project with TS 4.8, following errors are thrown:
node_modules/.prisma/client/index.d.ts:1144:45 - error TS2344: Type 'S["include"][P]' does not satisfy the constraint 'boolean | UserArgs | null | undefined'.
Type 'S["include"]["author"]' is not assignable to type 'boolean | UserArgs | null | undefined'.
Type 'S["include"]["author"]' is not assignable to type 'boolean | UserArgs | null | undefined'.
Type 'S["include"]["author"]' is not assignable to type 'UserArgs'.
Type 'S["include"]["author"]' is not assignable to type 'UserArgs'.
Type 'S["include"][P]' is not assignable to type 'UserArgs'.
Type 'S["include"]["author"]' is not assignable to type 'UserArgs'.
Type 'S["include"]["author"]' is not assignable to type 'UserArgs'.
1144 P extends 'author' ? UserGetPayload<S['include'][P]> : never
~~~~~~~~~~~~~~~
node_modules/.prisma/client/index.d.ts:1175:18 - error TS2344: Type 'GlobalRejectSettings' does not satisfy the constraint 'RejectOnNotFound | RejectPerOperation | undefined'.
Type 'GlobalRejectSettings' is not assignable to type 'RejectPerOperation'.
1175 ): HasReject<GlobalRejectSettings, LocalRejectSettings, 'findUnique', 'Post'> extends True ? CheckSelect<T, Prisma__PostClient<Post>, Prisma__PostClient<PostGetPayload<T>>> : CheckSelect<T, Prisma__PostClient<Post | null >, Prisma__PostClient<PostGetPayload<T> | null >>
~~~~~~~~~~~~~~~~~~~~
node_modules/.prisma/client/index.d.ts:1161:33
1161 export interface PostDelegate<GlobalRejectSettings> {
~~~~~~~~~~~~~~~~~~~~
This type parameter might need an `extends RejectPerOperation` constraint.
node_modules/.prisma/client/index.d.ts:1161:33
1161 export interface PostDelegate<GlobalRejectSettings> {
~~~~~~~~~~~~~~~~~~~~
This type parameter might need an `extends RejectOnNotFound | RejectPerOperation | undefined` constraint.
node_modules/.prisma/client/index.d.ts:1192:18 - error TS2344: Type 'GlobalRejectSettings' does not satisfy the constraint 'RejectOnNotFound | RejectPerOperation | undefined'.
1192 ): HasReject<GlobalRejectSettings, LocalRejectSettings, 'findFirst', 'Post'> extends True ? CheckSelect<T, Prisma__PostClient<Post>, Prisma__PostClient<PostGetPayload<T>>> : CheckSelect<T, Prisma__PostClient<Post | null >, Prisma__PostClient<PostGetPayload<T> | null >>
~~~~~~~~~~~~~~~~~~~~
node_modules/.prisma/client/index.d.ts:1161:33
1161 export interface PostDelegate<GlobalRejectSettings> {
~~~~~~~~~~~~~~~~~~~~
This type parameter might need an `extends RejectOnNotFound | RejectPerOperation | undefined` constraint.
node_modules/.prisma/client/index.d.ts:2119:18 - error TS2344: Type 'GlobalRejectSettings' does not satisfy the constraint 'RejectOnNotFound | RejectPerOperation | undefined'.
Type 'GlobalRejectSettings' is not assignable to type 'RejectPerOperation'.
2119 ): HasReject<GlobalRejectSettings, LocalRejectSettings, 'findUnique', 'Profile'> extends True ? CheckSelect<T, Prisma__ProfileClient<Profile>, Prisma__ProfileClient<ProfileGetPayload<T>>> : CheckSelect<T, Prisma__ProfileClient<Profile | null >, Prisma__ProfileClient<ProfileGetPayload<T> | null >>
~~~~~~~~~~~~~~~~~~~~
node_modules/.prisma/client/index.d.ts:2105:36
2105 export interface ProfileDelegate<GlobalRejectSettings> {
~~~~~~~~~~~~~~~~~~~~
This type parameter might need an `extends RejectPerOperation` constraint.
node_modules/.prisma/client/index.d.ts:2105:36
2105 export interface ProfileDelegate<GlobalRejectSettings> {
~~~~~~~~~~~~~~~~~~~~
This type parameter might need an `extends RejectOnNotFound | RejectPerOperation | undefined` constraint.
node_modules/.prisma/client/index.d.ts:2136:18 - error TS2344: Type 'GlobalRejectSettings' does not satisfy the constraint 'RejectOnNotFound | RejectPerOperation | undefined'.
2136 ): HasReject<GlobalRejectSettings, LocalRejectSettings, 'findFirst', 'Profile'> extends True ? CheckSelect<T, Prisma__ProfileClient<Profile>, Prisma__ProfileClient<ProfileGetPayload<T>>> : CheckSelect<T, Prisma__ProfileClient<Profile | null >, Prisma__ProfileClient<ProfileGetPayload<T> | null >>
~~~~~~~~~~~~~~~~~~~~
node_modules/.prisma/client/index.d.ts:2105:36
2105 export interface ProfileDelegate<GlobalRejectSettings> {
~~~~~~~~~~~~~~~~~~~~
This type parameter might need an `extends RejectOnNotFound | RejectPerOperation | undefined` constraint.
node_modules/.prisma/client/index.d.ts:3032:52 - error TS2344: Type 'S["include"][P]' does not satisfy the constraint 'boolean | PostArgs | null | undefined'.
Type 'S["include"]["posts"]' is not assignable to type 'boolean | PostArgs | null | undefined'.
Type 'S["include"]["posts"]' is not assignable to type 'boolean | PostArgs | null | undefined'.
Type 'S["include"]["posts"]' is not assignable to type 'PostArgs'.
Type 'S["include"]["posts"]' is not assignable to type 'PostArgs'.
Type 'S["include"][P]' is not assignable to type 'PostArgs'.
Type 'S["include"]["posts"]' is not assignable to type 'PostArgs'.
Type 'S["include"]["posts"]' is not assignable to type 'PostArgs'.
3032 P extends 'posts' ? Array < PostGetPayload<S['include'][P]>> :
~~~~~~~~~~~~~~~
node_modules/.prisma/client/index.d.ts:3033:49 - error TS2344: Type 'S["include"][P]' does not satisfy the constraint 'boolean | ProfileArgs | null | undefined'.
Type 'S["include"]["profile"]' is not assignable to type 'boolean | ProfileArgs | null | undefined'.
Type 'S["include"]["profile"]' is not assignable to type 'boolean | ProfileArgs | null | undefined'.
Type 'S["include"]["profile"]' is not assignable to type 'ProfileArgs'.
Type 'S["include"]["profile"]' is not assignable to type 'ProfileArgs'.
Type 'S["include"][P]' is not assignable to type 'ProfileArgs'.
Type 'S["include"]["profile"]' is not assignable to type 'ProfileArgs'.
Type 'S["include"]["profile"]' is not assignable to type 'ProfileArgs'.
3033 P extends 'profile' ? ProfileGetPayload<S['include'][P]> | null :
~~~~~~~~~~~~~~~
node_modules/.prisma/client/index.d.ts:3034:60 - error TS2344: Type 'S["include"][P]' does not satisfy the constraint 'boolean | UserCountOutputTypeArgs | null | undefined'.
Type 'S["include"]["_count"]' is not assignable to type 'boolean | UserCountOutputTypeArgs | null | undefined'.
Type 'S["include"]["_count"]' is not assignable to type 'boolean | UserCountOutputTypeArgs | null | undefined'.
3034 P extends '_count' ? UserCountOutputTypeGetPayload<S['include'][P]> : never
~~~~~~~~~~~~~~
node_modules/.prisma/client/index.d.ts:3041:60 - error TS2344: Type 'S["select"][P]' does not satisfy the constraint 'boolean | UserCountOutputTypeArgs | null | undefined'.
Type 'S["select"]["_count"]' is not assignable to type 'boolean | UserCountOutputTypeArgs | null | undefined'.
Type 'S["select"]["_count"]' is not assignable to type 'boolean | UserCountOutputTypeArgs | null | undefined'.
3041 P extends '_count' ? UserCountOutputTypeGetPayload<S['select'][P]> : P extends keyof User ? User[P] : never
~~~~~~~~~~~~~~
node_modules/.prisma/client/index.d.ts:3067:18 - error TS2344: Type 'GlobalRejectSettings' does not satisfy the constraint 'RejectOnNotFound | RejectPerOperation | undefined'.
Type 'GlobalRejectSettings' is not assignable to type 'RejectPerOperation'.
How to reproduce
Try running tsc on a Prisma project with TypeScript 4.8
Expected behavior
tsc successfully compiles project
Prisma information
Schema:
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
model Post {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
title String @db.VarChar(255)
content String?
published Boolean @default(false)
author User @relation(fields: [authorId], references: [id])
authorId Int
}
model Profile {
id Int @id @default(autoincrement())
bio String?
user User @relation(fields: [userId], references: [id])
userId Int @unique
}
model User {
id Int @id @default(autoincrement())
email String @unique
name String?
posts Post[]
profile Profile?
}
Repository:
import type { PrismaClient, User } from '@prisma/client'
export type CreateUserRow = Omit<User, 'id'>
export class UserRepository {
private readonly prisma: PrismaClient
constructor(prisma: PrismaClient) {
this.prisma = prisma
}
async getUser(id: number): Promise<User | null> {
const user = await this.prisma.user.findUnique({
where: {
id,
},
})
return user
}
async createUser(user: CreateUserRow): Promise<User> {
const createdUser = await this.prisma.user.create({
data: user,
})
return createdUser
}
}Environment & setup
TypeScript 4.8.2
Prisma Version
Prisma 4.2.1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bug/2-confirmedBug has been reproduced and confirmed.Bug has been reproduced and confirmed.kind/bugA reported bug.A reported bug.tech/typescriptIssue for tech TypeScript.Issue for tech TypeScript.topic: prisma-client