Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript errors in the generated router #78

Open
atanaskanchev opened this issue Mar 9, 2023 · 5 comments
Open

Typescript errors in the generated router #78

atanaskanchev opened this issue Mar 9, 2023 · 5 comments

Comments

@atanaskanchev
Copy link

Bug description

The generated router at generated/routers/Post.router.ts

 createOnePost: protectedProcedure
    .input(PostCreateOneSchema).mutation(async ({ ctx, input }) => {
      const createOnePost = await ctx.prisma.post.create(input);
      return createOnePost;
    }),

has the following error

Argument of type '{ data: (PostCreateInput | PostUncheckedCreateInput) & (PostCreateInput | PostUncheckedCreateInput | undefined); }' is not assignable to parameter of type '{ select?: PostSelect | null | undefined; include?: PostInclude | null | undefined; data: (Without<PostCreateInput, PostUncheckedCreateInput> & PostUncheckedCreateInput) | (Without<...> & PostCreateInput); }'.
  Types of property 'data' are incompatible.
    Type '(PostCreateInput | PostUncheckedCreateInput) & (PostCreateInput | PostUncheckedCreateInput | undefined)' is not assignable to type '(Without<PostCreateInput, PostUncheckedCreateInput> & PostUncheckedCreateInput) | (Without<...> & PostCreateInput)'.
      Type 'PostCreateInput & PostUncheckedCreateInput' is not assignable to type '(Without<PostCreateInput, PostUncheckedCreateInput> & PostUncheckedCreateInput) | (Without<...> & PostCreateInput)'.
        Type 'PostCreateInput & PostUncheckedCreateInput' is not assignable to type 'Without<PostUncheckedCreateInput, PostCreateInput> & PostCreateInput'.
          Type 'PostCreateInput & PostUncheckedCreateInput' is not assignable to type 'Without<PostUncheckedCreateInput, PostCreateInput>'.
            Types of property 'id' are incompatible.
              Type 'number | undefined' is not assignable to type 'undefined'.
                Type 'number' is not assignable to type 'undefined'.ts(2345)

How to reproduce

  1. Use the sample schema

Expected behavior

No response

Prisma information

generator client {
provider = "prisma-client-js"
}

generator trpc {
provider = "prisma-trpc-generator"
// output = "../../trpc/init/src/generated"
output = "./generated"
withMiddleware = "../../trpc/init/src/middleware"
withShield = false
contextPath = "../../trpc/init/src/context"
trpcOptionsPath = "../../trpc/init/src/trpcOptions"
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}

model User {
id Int @id @default(autoincrement())
email String @unique
name String?
posts Post[]
books Book[]
}

model Post {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
title String
content String?
published Boolean @default(false)
viewCount Int @default(0)
author User? @relation(fields: [authorId], references: [id])
authorId Int?
likes BigInt
}

/// @@Gen.model(hide: true)
model Book {
id Int @unique
title String
author User? @relation(fields: [authorId], references: [id])
authorId Int?
}

model Map {
key String @id
value String
}

Environment & setup

  • OS: MacOS
  • Database: Postgres
  • Node.js version:18

Prisma Version

4.11.0
@Frumba
Copy link

Frumba commented Mar 9, 2023

I am having the same issue since today 🙏

@ymc9
Copy link

ymc9 commented Mar 14, 2023

Seems to be a zod issue:
colinhacks/zod#2184

Downgrading to zod 3.21.1 worked for me.

@jamesrweb
Copy link

Just hit this issue today also.

@okeeffed
Copy link

I also hit this issue. Subbing to notifications.

@peterarusanoff
Copy link

peterarusanoff commented Oct 23, 2023

I am having the same issue Here

I am getting a whole list of errors

106 Errors

nonexisting prisma exports:
AccountUncheckedUpdateManyWithoutAccountsInput'. Did you mean 'AccountUncheckedUpdateManyWithoutUserInput'?

type issues:

are the majority
Type 'undefined' is not assignable to type 'string | AccountProviderProviderAccountIdCompoundUniqueInput'.
Type 'number | number[] | undefined' is not assignable to type 'number[] | undefined'.
Type 'number | number[] | null | undefined' is not assignable to type 'number[] | null | undefined'.

Prisma: "^5.3.0"
zod: "3.21.1"
@prisma/client: "5.3.0",
DB: MongoDB

Please let me know of a work around

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants