From e47f6b424cf7f849ed9a9aa2f8f9fb70dacf3b27 Mon Sep 17 00:00:00 2001 From: Andrew Bastin Date: Tue, 14 Nov 2023 21:06:55 +0530 Subject: [PATCH] fix: InferredEntity not dealing with catch schemas properly --- package.json | 2 +- src/index.ts | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 16476f4..c4d94b7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "verzod", - "version": "0.2.0", + "version": "0.2.2", "license": "MIT", "description": "A simple versioning and migration library based on Zod schemas", "author": "Andrew Bastin (andrewbastin.k@gmail.com)", diff --git a/src/index.ts b/src/index.ts index 58cb563..e19665c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,11 +3,11 @@ import { z } from "zod"; /** * Defines a version of a Verzod entity schema and how to upgrade from the previous version. */ -export type Version = { +export type Version = { /** * The schema for this version of the entity. */ - schema: z.ZodType; + schema: NewScheme; } & ( | { /** @@ -27,7 +27,7 @@ export type Version = { * * @returns The data as in the new version of the schema */ - up: (old: OldScheme) => NewScheme; + up: (old: OldScheme) => z.infer; } ); @@ -39,7 +39,7 @@ export type Version = { * This is only used to help TypeScript infer the type of the given parameter cleanly. * @param def The version definition */ -export const defineVersion = ( +export const defineVersion = ( def: Version, ) => def; @@ -50,7 +50,7 @@ export type SchemaOf> = T extends Version< infer S, any > - ? S + ? z.infer : never; /** @@ -91,7 +91,7 @@ export type ParseResult = * The definition of the version of the data * corresponding to the determined version */ - versionDef: Version; + versionDef: Version; /** * The `ZodError` returned by the schema validation.