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

Type error in the StringFilter.schema #83

Open
fcaride opened this issue Aug 25, 2023 · 1 comment
Open

Type error in the StringFilter.schema #83

fcaride opened this issue Aug 25, 2023 · 1 comment

Comments

@fcaride
Copy link

fcaride commented Aug 25, 2023

Bug description

I just generated all the stuff with the "withZod" flag and th StringFilter.schema.ts file resulted like this:

const Schema: z.ZodType<Prisma.StringFilter> = z
  .object({
    equals: z.string().optional(),
    in: z.union([z.string().array(), z.string()]).optional(),
    notIn: z.union([z.string().array(), z.string()]).optional(),
    lt: z.string().optional(),
    lte: z.string().optional(),
    gt: z.string().optional(),
    gte: z.string().optional(),
    contains: z.string().optional(),
    startsWith: z.string().optional(),
    endsWith: z.string().optional(),
    not: z
      .union([z.string(), z.lazy(() => NestedStringFilterObjectSchema)])
      .optional(),
  })
  .strict();

export const StringFilterObjectSchema = Schema;

But its getting this error:
Type 'ZodObject<{ equals: ZodOptional<ZodString>; in: ZodOptional<ZodUnion<[ZodArray<ZodString, "many">, ZodString]>>; ... 8 more ...; not: ZodOptional<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>' is not assignable to type 'ZodType<StringFilter<never>, ZodTypeDef, StringFilter<never>>'. The types of '_type.in' are incompatible between these types. Type 'string | string[] | undefined' is not assignable to type 'string[] | undefined'. Type 'string' is not assignable to type 'string[]'.ts(2322)

If i change the lines of in and notIn to this it works fine: z.string().array().optional()

How to reproduce

Generate the prisma files of any Module.

"prisma-trpc-generator": "^1.4.1", "@prisma/client": "^5.1.1", "@trpc/client": "^10.34.0",

Expected behavior

To no have any type error

Prisma information

generator trpc {
    provider                 = "prisma-trpc-generator"
    withMiddleware           = "../src/server/api/trpcMiddleware"
    withZod                  = true
    withShield               = false
    contextPath              = "../src/server/api/trpc"
    trpcOptionsPath          = "../src/server/api/trpc"
    showModelNameInProcedure = false
    generateModelActions     = "create,delete,deleteMany,findMany,update,updateMany"
    isGenerateInclude        = true
}

model Example {
    id       String     @id @unique @default(cuid())
    name     String     @unique
}

Environment & setup

"prisma-trpc-generator": "^1.4.1",
"@prisma/client": "^5.1.1",
"@trpc/client": "^10.34.0",

Prisma Version

5.1.1
@linkfang
Copy link

I have similar issues on a few types, (date and field realted), and I think that's because we are using Prisma V5.X which is not supported by this library atm

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