ts-to-zod
ts-to-zod copied to clipboard
Property shape does not exist on type ZodType
Bug description
ts-to-zod v3.0.0 generates a Zod schema that fails type verification with this error:
2339: Property 'shape' does not exist on type 'ZodType<test, ZodTypeDef, test>'.
Looking into the ZodType
(exported as ZodSchema
) definition it in fact doesn't have any field called shape
.
Input
The input file is generated by openapi-typescript
v6.2.0 but I could reproduce the issue with a type definition as simple as this:
// typescript type or interface causing the output
export interface test {
schemas: {
A: string | null;
B: test['schemas']['A'][];
};
}
Expected output
Not exactly sure ...
Actual output
// Actual Zod schemas
// Generated by ts-to-zod
import { z } from 'zod';
import { test } from './test.d';
export const testSchema: z.ZodSchema<test> = z.lazy(() =>
z.object({
schemas: z.object({
A: z.string().nullable(),
B: z.array(testSchema.shape.schemas.shape.A),
}),
}),
);
Versions
- Typescript:
v4.9.5
- Zod:
v3.21.4
Hi, any update ?
Btw, this issue is not relevant to me anymore since we switched from openapi-typescript + ts-to-zod to openapi-zod-client.
We're still not supporting zod v3.21.4+?