From f5e7c3287c49529bd28f0369fb7350e7b652660f Mon Sep 17 00:00:00 2001 From: Misha Kaletsky Date: Fri, 31 May 2024 14:28:06 -0400 Subject: [PATCH] less casting --- src/zod-procedure.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/zod-procedure.ts b/src/zod-procedure.ts index 24ef964..31ffb43 100644 --- a/src/zod-procedure.ts +++ b/src/zod-procedure.ts @@ -41,8 +41,8 @@ export function parseProcedureInputs(inputs: unknown[]): Result return parseLiteralInput(mergedSchema) } - if (looksLikeInstanceof(mergedSchema, z.ZodTuple)) { - return parseTupleInput(mergedSchema as z.ZodTuple) + if (looksLikeInstanceof>(mergedSchema, z.ZodTuple)) { + return parseTupleInput(mergedSchema) } if (!acceptsObject(mergedSchema)) { @@ -230,12 +230,12 @@ export function accepts(target: ZodTarget) { const innerType = getInnerType(zodType) if (looksLikeInstanceof(innerType, target.constructor as new (...args: unknown[]) => ZodTarget)) return true if (looksLikeInstanceof(innerType, z.ZodLiteral)) return target.safeParse(innerType.value).success - if (looksLikeInstanceof(innerType, z.ZodEnum)) - return (innerType.options as unknown[]).some(o => target.safeParse(o).success) + if (looksLikeInstanceof(innerType, z.ZodEnum)) return innerType.options.some(o => target.safeParse(o).success) if (looksLikeInstanceof(innerType, z.ZodUnion)) return innerType.options.some(test) - if (looksLikeInstanceof(innerType, z.ZodIntersection)) - return test(innerType._def.left as z.ZodType) && test(innerType._def.right as z.ZodType) - if (looksLikeInstanceof(innerType, z.ZodEffects)) return test(innerType.innerType() as z.ZodType) + if (looksLikeInstanceof>(innerType, z.ZodEffects)) return test(innerType.innerType()) + if (looksLikeInstanceof>(innerType, z.ZodIntersection)) + return test(innerType._def.left) && test(innerType._def.right) + return false } return test