Revision 0.8.2 (#11)

* Ensure Type Evaluation at Mapping Signature

* Version
This commit is contained in:
sinclairzx81
2025-01-26 16:29:26 +09:00
committed by GitHub
parent 3c03dbf43d
commit 6a7f983e94
6 changed files with 24 additions and 20 deletions

View File

@@ -35,17 +35,17 @@ import * as z from 'zod'
/** Creates a Zod type from Syntax or another Type */
// prettier-ignore
export type TZod<Type extends object | string> = (
export type TZod<Type extends object | string, Result = (
Guard.TIsSyntax<Type> extends true ? TZodFromSyntax<Type> :
Guard.TIsTypeBox<Type> extends true ? TZodFromTypeBox<Type> :
Guard.TIsValibot<Type> extends true ? TZodFromValibot<Type> :
Guard.TIsZod<Type> extends true ? TZodFromZod<Type> :
z.ZodNever
)
)> = Result
/** Creates a Zod type from Syntax or another Type */
// prettier-ignore
export function Zod<Type extends object | string, Result = TZod<Type>>(type: Type): Result {
export function Zod<Type extends object | string, Mapped = TZod<Type>, Result extends Mapped = Mapped>(type: Type): Result {
return (
Guard.IsSyntax(type) ? ZodFromSyntax(type) :
Guard.IsTypeBox(type) ? ZodFromTypeBox(type) :