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,13 +35,14 @@ import * as t from '@sinclair/typebox'
/** Creates a TypeBox type from Syntax or another Type */
// prettier-ignore
export type TTypeBox<Type extends object | string> = (
export type TTypeBox<Type extends object | string, Result = (
Guard.TIsSyntax<Type> extends true ? TTypeBoxFromSyntax<Type> :
Guard.TIsTypeBox<Type> extends true ? TTypeBoxFromTypeBox<Type> :
Guard.TIsValibot<Type> extends true ? TTypeBoxFromValibot<Type> :
Guard.TIsZod<Type> extends true ? TTypeBoxFromZod<Type> :
t.TNever
)
)> = Result
/** Creates a TypeBox type from Syntax or another Type */
// prettier-ignore
export function TypeBox<Type extends object | string>(type: Type): TTypeBox<Type> {
@@ -58,6 +59,6 @@ export function TypeBox<Type extends object | string>(type: Type): TTypeBox<Type
* Creates a TypeBox type from Syntax or another Type
* @deprecated Use TypeBox() export instead
*/
export function Box<Type extends object | string>(type: Type): TTypeBox<Type> {
return TypeBox(type)
export function Box<Type extends object | string, Mapped = TTypeBox<Type>, Result extends Mapped = Mapped>(type: Type): Result {
return TypeBox(type) as never
}