Skip to content

Commit

Permalink
fix: InferredEntity not dealing with catch schemas properly
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewBastin committed Nov 14, 2023
1 parent dac205d commit e47f6b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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 ([email protected])",
Expand Down
12 changes: 6 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<NewScheme, OldScheme> = {
export type Version<NewScheme extends z.ZodType, OldScheme> = {
/**
* The schema for this version of the entity.
*/
schema: z.ZodType<NewScheme>;
schema: NewScheme;
} & (
| {
/**
Expand All @@ -27,7 +27,7 @@ export type Version<NewScheme, OldScheme> = {
*
* @returns The data as in the new version of the schema
*/
up: (old: OldScheme) => NewScheme;
up: (old: OldScheme) => z.infer<NewScheme>;
}
);

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

Expand All @@ -50,7 +50,7 @@ export type SchemaOf<T extends Version<any, any>> = T extends Version<
infer S,
any
>
? S
? z.infer<S>
: never;

/**
Expand Down Expand Up @@ -91,7 +91,7 @@ export type ParseResult<T> =
* The definition of the version of the data
* corresponding to the determined version
*/
versionDef: Version<unknown, unknown>;
versionDef: Version<z.ZodType, unknown>;

/**
* The `ZodError` returned by the schema validation.
Expand Down

0 comments on commit e47f6b4

Please sign in to comment.