orval icon indicating copy to clipboard operation
orval copied to clipboard

Zod: generation of typed tuples produces illegal zod array syntax

Open helt opened this issue 6 months ago • 6 comments

What are the steps to reproduce this issue?

  1. check out referenced PR
  2. in tests: generate and build

What happens?

zod generator produces zod.array(), which is illegal syntax since error TS2554: Expected 1-2 arguments, but got 0.

What were you expecting to happen?

Produce a typed tuple, similar to:

zod.tuple(zod.string(), zod.object())

Any logs, error output, etc?

generated/zod/example-v3-1.ts:25:24 - error TS2554: Expected 1-2 arguments, but got 0.

25   "example_tuple": zod.array().min(postApiSampleResponseExampleTupleMin).max(postApiSampleResponseExampleTupleMax).optional(),
                          ~~~~~~~

  node_modules/zod/lib/types.d.ts:1055:49
    1055 declare const arrayType: <T extends ZodTypeAny>(schema: T, params?: RawCreateParams) => ZodArray<T, "many">;
                                                         ~~~~~~~~~
    An argument for 'schema' was not provided.

Any other comments?

more issues pop up which are not my main concern, currently.

What versions are you using?

npx envinfo --system --npmPackages orval,zod,axios,msw,swr,@tanstack/react-query,@tanstack/vue-query,react,vue
Need to install the following packages:
[email protected]
Ok to proceed? (y) y

  System:
    OS: Linux 5.15 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
    CPU: (8) x64 Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz
    Memory: 13.61 GB / 31.31 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  npmPackages:
    @tanstack/react-query: ^4.22.0 => 4.22.0 
    @tanstack/vue-query: ^4.22.0 => 4.22.0 
    axios: ^0.26.1 => 0.26.1 
    msw: ^2.0.2 => 2.0.2 
    react: ^18.3.1 => 18.3.1 
    swr: ^2.2.4 => 2.2.4 
    vue: ^3.3.4 => 3.3.4 
    zod: ^3.23.8 => 3.23.8 

helt avatar Aug 20 '24 12:08 helt