Skip to content

Commit

Permalink
Fix superrefine types
Browse files Browse the repository at this point in the history
  • Loading branch information
colinhacks committed Aug 19, 2023
1 parent 8e4af7b commit 792b3ef
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
5 changes: 4 additions & 1 deletion deno/lib/types.ts
Expand Up @@ -371,7 +371,10 @@ export abstract class ZodType<
refinement: (arg: Output, ctx: RefinementCtx) => arg is RefinedOutput
): ZodEffects<this, RefinedOutput, Input>;
superRefine(
refinement: (arg: Output, ctx: RefinementCtx) => void | Promise<void>
refinement: (arg: Output, ctx: RefinementCtx) => void
): ZodEffects<this, Output, Input>;
superRefine(
refinement: (arg: Output, ctx: RefinementCtx) => Promise<void>
): ZodEffects<this, Output, Input>;
superRefine(
refinement: (arg: Output, ctx: RefinementCtx) => unknown | Promise<unknown>
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "zod",
"version": "3.22.1",
"version": "3.22.2",
"author": "Colin McDonnell <colin@colinhacks.com>",
"repository": {
"type": "git",
Expand Down
9 changes: 9 additions & 0 deletions playground.ts
@@ -1,3 +1,12 @@
import { z } from "./src";

z;

const schema = z.object({
name: z.string(),
value: z.string(),
});

const schemaRefine = schema.superRefine(async (val, _ctx) => {
return val.value !== "INVALID";
});
5 changes: 4 additions & 1 deletion src/types.ts
Expand Up @@ -371,7 +371,10 @@ export abstract class ZodType<
refinement: (arg: Output, ctx: RefinementCtx) => arg is RefinedOutput
): ZodEffects<this, RefinedOutput, Input>;
superRefine(
refinement: (arg: Output, ctx: RefinementCtx) => void | Promise<void>
refinement: (arg: Output, ctx: RefinementCtx) => void
): ZodEffects<this, Output, Input>;
superRefine(
refinement: (arg: Output, ctx: RefinementCtx) => Promise<void>
): ZodEffects<this, Output, Input>;
superRefine(
refinement: (arg: Output, ctx: RefinementCtx) => unknown | Promise<unknown>
Expand Down

0 comments on commit 792b3ef

Please sign in to comment.