Skip to content

zenstack generate: Error compiling generated code #2193

@reznakt

Description

@reznakt

Description and expected behavior

When running zenstack generate, the generation fails during the "Generating Zod schemas" phase with the following error:

Error compiling generated code:
../../node_modules/zod/v4/classic/schemas.d.cts:455:31 - error TS1139: Type parameter declaration expected.

455 export declare function union<const T extends readonly core.SomeType[]>(options: T, params?: string | core.$ZodUnionParams): ZodUnion<T>;
                                  ~~~~~
../../node_modules/zod/v4/classic/schemas.d.cts:455:39 - error TS1005: ',' expected.

455 export declare function union<const T extends readonly core.SomeType[]>(options: T, params?: string | core.$ZodUnionParams): ZodUnion<T>;
                                          ~~~~~~~
../../node_modules/zod/v4/classic/schemas.d.cts:455:56 - error TS1005: ',' expected.

455 export declare function union<const T extends readonly core.SomeType[]>(options: T, params?: string | core.$ZodUnionParams): ZodUnion<T>;
                                                           ~~~~
../../node_modules/zod/v4/classic/schemas.d.cts:455:60 - error TS1005: ',' expected.

455 export declare function union<const T extends readonly core.SomeType[]>(options: T, params?: string | core.$ZodUnionParams): ZodUnion<T>;
                                                               ~
../../node_modules/zod/v4/classic/schemas.d.cts:455:69 - error TS1005: ',' expected.

455 export declare function union<const T extends readonly core.SomeType[]>(options: T, params?: string | core.$ZodUnionParams): ZodUnion<T>;
                                                                        ~
../../node_modules/zod/v4/classic/schemas.d.cts:455:71 - error TS1005: ',' expected.

455 export declare function union<const T extends readonly core.SomeType[]>(options: T, params?: string | core.$ZodUnionParams): ZodUnion<T>;
                                                                          ~
../../node_modules/zod/v4/classic/schemas.d.cts:455:80 - error TS1005: ')' expected.

455 export declare function union<const T extends readonly core.SomeType[]>(options: T, params?: string | core.$ZodUnionParams): ZodUnion<T>;
                                                                                   ~
../../node_modules/zod/v4/classic/schemas.d.cts:455:92 - error TS1109: Expression expected.

455 export declare function union<const T extends readonly core.SomeType[]>(options: T, params?: string | core.$ZodUnionParams): ZodUnion<T>;
                                                                                               ~
../../node_modules/zod/v4/classic/schemas.d.cts:455:123 - error TS1005: ';' expected.

455 export declare function union<const T extends readonly core.SomeType[]>(options: T, params?: string | core.$ZodUnionParams): ZodUnion<T>;
                                                                                                                              ~
../../node_modules/zod/v4/classic/schemas.d.cts:455:124 - error TS1128: Declaration or statement expected.

455 export declare function union<const T extends readonly core.SomeType[]>(options: T, params?: string | core.$ZodUnionParams): ZodUnion<T>;
                                                                                                                               ~

: Error compiling generated code

Environment (please complete the following information):

  • Bun version: 1.2.18
  • ZenStack version: 2.16.1
  • Prisma version: 6.11.1
  • Database type: PostgreSQL

Additional context

I have managed to reproduce the error with code as minimal as this:

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

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

model User {
  id        Int    @id @default(autoincrement())
  firstName String @length(1, 50)
}

It appears that any use of the zod plugin results in this error. When the @length(1, 50) constraint is removed, the plugin is disabled and everything works just fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions