Skip to content

Commit 36369f4

Browse files
Fix issue with parsing inner Zod V4 definitions (#1198)
1 parent a5b8f15 commit 36369f4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/server/zod-compat.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export interface ZodV3Internal {
3131
export interface ZodV4Internal {
3232
_zod?: {
3333
def?: {
34-
typeName?: string;
34+
type?: string;
3535
value?: unknown;
3636
values?: unknown[];
3737
shape?: Record<string, AnySchema> | (() => Record<string, AnySchema>);
@@ -175,7 +175,7 @@ export function normalizeObjectSchema(schema: AnySchema | ZodRawShapeCompat | un
175175
// Check if it's a v4 object
176176
const v4Schema = schema as unknown as ZodV4Internal;
177177
const def = v4Schema._zod?.def;
178-
if (def && (def.typeName === 'object' || def.shape !== undefined)) {
178+
if (def && (def.type === 'object' || def.shape !== undefined)) {
179179
return schema as AnyObjectSchema;
180180
}
181181
} else {
@@ -238,7 +238,7 @@ export function getSchemaDescription(schema: AnySchema): string | undefined {
238238
export function isSchemaOptional(schema: AnySchema): boolean {
239239
if (isZ4Schema(schema)) {
240240
const v4Schema = schema as unknown as ZodV4Internal;
241-
return v4Schema._zod?.def?.typeName === 'ZodOptional';
241+
return v4Schema._zod?.def?.type === 'optional';
242242
}
243243
const v3Schema = schema as unknown as ZodV3Internal;
244244
// v3 has isOptional() method

0 commit comments

Comments
 (0)