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

TS2322 error in ModelACreateOrConnectWithoutModelBInputSchema #183

Closed
empz opened this issue Aug 30, 2023 · 1 comment
Closed

TS2322 error in ModelACreateOrConnectWithoutModelBInputSchema #183

empz opened this issue Aug 30, 2023 · 1 comment

Comments

@empz
Copy link

empz commented Aug 30, 2023

AppointmentCreateOrConnectWithoutCustomerInputSchema.ts (generated)

import type { Prisma } from "@prisma/client";
import { z } from "zod";
import { AppointmentCreateWithoutCustomerInputSchema } from "./AppointmentCreateWithoutCustomerInputSchema";
import { AppointmentUncheckedCreateWithoutCustomerInputSchema } from "./AppointmentUncheckedCreateWithoutCustomerInputSchema";
import { AppointmentWhereUniqueInputSchema } from "./AppointmentWhereUniqueInputSchema";

export const AppointmentCreateOrConnectWithoutCustomerInputSchema: z.ZodType<Prisma.AppointmentCreateOrConnectWithoutCustomerInput> =
  z
    .object({
      where: z.lazy(() => AppointmentWhereUniqueInputSchema),
      create: z.union([
        z.lazy(() => AppointmentCreateWithoutCustomerInputSchema),
        z.lazy(() => AppointmentUncheckedCreateWithoutCustomerInputSchema),
      ]),
    })
    .strict();

export default AppointmentCreateOrConnectWithoutCustomerInputSchema;

Error

Type 'ZodObject<{ where: ZodLazy<ZodType<AppointmentWhereUniqueInput, ZodTypeDef, AppointmentWhereUniqueInput>>; create: ZodUnion<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>' is not assignable to type 'ZodType<AppointmentCreateOrConnectWithoutCustomerInput, ZodTypeDef, AppointmentCreateOrConnectWithoutCustomerInput>'.
  The types of '_type.create' are incompatible between these types.
    Type '(AppointmentCreateWithoutCustomerInput | AppointmentUncheckedCreateWithoutCustomerInput) & (AppointmentCreateWithoutCustomerInput | ... 1 more ... | undefined)' is not assignable to type '(Without<AppointmentCreateWithoutCustomerInput, AppointmentUncheckedCreateWithoutCustomerInput> & AppointmentUncheckedCreateWithoutCustomerInput) | (Without<...> & AppointmentCreateWithoutCustomerInput)'.
      Type 'AppointmentCreateWithoutCustomerInput & AppointmentUncheckedCreateWithoutCustomerInput' is not assignable to type '(Without<AppointmentCreateWithoutCustomerInput, AppointmentUncheckedCreateWithoutCustomerInput> & AppointmentUncheckedCreateWithoutCustomerInput) | (Without<...> & AppointmentCreateWithoutCustomerInput)'.
        Type 'AppointmentCreateWithoutCustomerInput & AppointmentUncheckedCreateWithoutCustomerInput' is not assignable to type 'Without<AppointmentUncheckedCreateWithoutCustomerInput, AppointmentCreateWithoutCustomerInput> & AppointmentCreateWithoutCustomerInput'.
          Type 'AppointmentCreateWithoutCustomerInput & AppointmentUncheckedCreateWithoutCustomerInput' is not assignable to type 'Without<AppointmentUncheckedCreateWithoutCustomerInput, AppointmentCreateWithoutCustomerInput>'.
            Types of property 'id' are incompatible.
              Type 'number | undefined' is not assignable to type 'undefined'.
                Type 'number' is not assignable to type 'undefined'.

schema.prisma (simplified)

model Customer {
    id           Int           @id @default(autoincrement())
    fullName     String
    email        String?
    createdAt    DateTime      @default(now())
    updatedAt    DateTime      @updatedAt
    appointments Appointment[]
}

model Appointment {
    id                Int               @id @default(autoincrement())
    start             DateTime
    end               DateTime
    createdAt         DateTime          @default(now())
    updatedAt         DateTime          @updatedAt
    customer          Customer          @relation(fields: [customerId], references: [id], onDelete: Cascade)
    customerId        Int
}
  • Prisma 5.2.0
  • zod 3.22.2
  • zod-prisma-types 2.7.9
@chrishoermann
Copy link
Owner

@empz sadly there is still an unresolved issue with zod versions greater than 3.21.1 - see here. So please use zod 3.21.1 for now.

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

2 participants