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

@@ -36,16 +36,16 @@ import * as c from './common'
/** Creates a Valibot type from Syntax or another Type */
// prettier-ignore
export type TValibot<Type extends object | string> = (
export type TValibot<Type extends object | string, Result = (
Guard.TIsSyntax<Type> extends true ? TValibotFromSyntax<Type> :
Guard.TIsTypeBox<Type> extends true ? TValibotFromTypeBox<Type> :
Guard.TIsValibot<Type> extends true ? TValibotFromValibot<Type> :
Guard.TIsZod<Type> extends true ? TValibotFromZod<Type> :
v.NeverSchema<c.BaseError>
)
)> = Result
/** Creates a Valibot type from Syntax or another Type */
// prettier-ignore
export function Valibot<Type extends object | string, Result = TValibot<Type>>(type: Type): Result {
export function Valibot<Type extends object | string, Mapped = TValibot<Type>, Result extends Mapped = Mapped>(type: Type): Result {
return (
Guard.IsSyntax(type) ? ValibotFromSyntax(type) :
Guard.IsTypeBox(type) ? ValibotFromTypeBox(type) :