Skip to content

Commit e47f6b4

Browse files
committed
fix: InferredEntity not dealing with catch schemas properly
1 parent dac205d commit e47f6b4

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "verzod",
3-
"version": "0.2.0",
3+
"version": "0.2.2",
44
"license": "MIT",
55
"description": "A simple versioning and migration library based on Zod schemas",
66
"author": "Andrew Bastin (andrewbastin.k@gmail.com)",

src/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import { z } from "zod";
33
/**
44
* Defines a version of a Verzod entity schema and how to upgrade from the previous version.
55
*/
6-
export type Version<NewScheme, OldScheme> = {
6+
export type Version<NewScheme extends z.ZodType, OldScheme> = {
77
/**
88
* The schema for this version of the entity.
99
*/
10-
schema: z.ZodType<NewScheme>;
10+
schema: NewScheme;
1111
} & (
1212
| {
1313
/**
@@ -27,7 +27,7 @@ export type Version<NewScheme, OldScheme> = {
2727
*
2828
* @returns The data as in the new version of the schema
2929
*/
30-
up: (old: OldScheme) => NewScheme;
30+
up: (old: OldScheme) => z.infer<NewScheme>;
3131
}
3232
);
3333

@@ -39,7 +39,7 @@ export type Version<NewScheme, OldScheme> = {
3939
* This is only used to help TypeScript infer the type of the given parameter cleanly.
4040
* @param def The version definition
4141
*/
42-
export const defineVersion = <NewScheme, OldScheme>(
42+
export const defineVersion = <NewScheme extends z.ZodType, OldScheme>(
4343
def: Version<NewScheme, OldScheme>,
4444
) => def;
4545

@@ -50,7 +50,7 @@ export type SchemaOf<T extends Version<any, any>> = T extends Version<
5050
infer S,
5151
any
5252
>
53-
? S
53+
? z.infer<S>
5454
: never;
5555

5656
/**
@@ -91,7 +91,7 @@ export type ParseResult<T> =
9191
* The definition of the version of the data
9292
* corresponding to the determined version
9393
*/
94-
versionDef: Version<unknown, unknown>;
94+
versionDef: Version<z.ZodType, unknown>;
9595

9696
/**
9797
* The `ZodError` returned by the schema validation.

0 commit comments

Comments
 (0)