diff --git a/package-lock.json b/package-lock.json index 8626e26..52ec389 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@sinclair/typemap", - "version": "0.8.17", + "version": "0.8.18", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@sinclair/typemap", - "version": "0.8.17", + "version": "0.8.18", "license": "MIT", "devDependencies": { "@arethetypeswrong/cli": "^0.17.2", diff --git a/package.json b/package.json index 2eb36d2..40e807b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@sinclair/typemap", - "version": "0.8.17", + "version": "0.8.18", "description": "Syntax Compiler and Translation System for Runtime Types", "author": "sinclairzx81", "license": "MIT", diff --git a/src/typebox/typebox-from-valibot.ts b/src/typebox/typebox-from-valibot.ts index 266698d..4a51750 100644 --- a/src/typebox/typebox-from-valibot.ts +++ b/src/typebox/typebox-from-valibot.ts @@ -262,7 +262,7 @@ function FromDate(type: BaseSchema): t.TSchema { // Enum // ------------------------------------------------------------------ t.TypeRegistry.Set('ValibotEnum', (schema, value) => { - return v.safeParse(schema.schema, value).success + return v.safeParse(schema.type, value).success }) export interface TValibotEnum = v.EnumSchema> extends t.TSchema { [t.Kind]: 'ValibotEnum' @@ -272,7 +272,10 @@ export interface TValibotEnum = v.EnumSch function ValibotEnum>(type: Type, options?: t.SchemaOptions): TValibotEnum { return t.CreateType({ [t.Kind]: 'ValibotEnum', type }, options) as never } -type TFromEnum> = TValibotEnum +// prettier-ignore +type TFromEnum, + Result = TValibotEnum +> = Result function FromEnum(type: Type): t.TSchema { return ValibotEnum(type as never as v.EnumSchema, Options(type)) } @@ -749,7 +752,7 @@ type TFromType = ( Type extends v.BooleanSchema ? TFromBoolean : Type extends v.CustomSchema ? TFromCustom : Type extends v.DateSchema ? TFromDate : - Type extends v.EnumSchema ? TFromEnum : + Type extends v.EnumSchema ? TFromEnum : // note: unable to match on v.Enum parameter. use any and push type through for mapping Type extends v.FileSchema ? TFromFile : Type extends v.FunctionSchema ? TFromFunction : Type extends v.InstanceSchema ? TFromInstance :