Skip to content

Commit 792b3ef

Browse files
committed
Fix superrefine types
1 parent 8e4af7b commit 792b3ef

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

deno/lib/types.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,10 @@ export abstract class ZodType<
371371
refinement: (arg: Output, ctx: RefinementCtx) => arg is RefinedOutput
372372
): ZodEffects<this, RefinedOutput, Input>;
373373
superRefine(
374-
refinement: (arg: Output, ctx: RefinementCtx) => void | Promise<void>
374+
refinement: (arg: Output, ctx: RefinementCtx) => void
375+
): ZodEffects<this, Output, Input>;
376+
superRefine(
377+
refinement: (arg: Output, ctx: RefinementCtx) => Promise<void>
375378
): ZodEffects<this, Output, Input>;
376379
superRefine(
377380
refinement: (arg: Output, ctx: RefinementCtx) => unknown | Promise<unknown>

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "zod",
3-
"version": "3.22.1",
3+
"version": "3.22.2",
44
"author": "Colin McDonnell <colin@colinhacks.com>",
55
"repository": {
66
"type": "git",

playground.ts

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
11
import { z } from "./src";
22

33
z;
4+
5+
const schema = z.object({
6+
name: z.string(),
7+
value: z.string(),
8+
});
9+
10+
const schemaRefine = schema.superRefine(async (val, _ctx) => {
11+
return val.value !== "INVALID";
12+
});

src/types.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,10 @@ export abstract class ZodType<
371371
refinement: (arg: Output, ctx: RefinementCtx) => arg is RefinedOutput
372372
): ZodEffects<this, RefinedOutput, Input>;
373373
superRefine(
374-
refinement: (arg: Output, ctx: RefinementCtx) => void | Promise<void>
374+
refinement: (arg: Output, ctx: RefinementCtx) => void
375+
): ZodEffects<this, Output, Input>;
376+
superRefine(
377+
refinement: (arg: Output, ctx: RefinementCtx) => Promise<void>
375378
): ZodEffects<this, Output, Input>;
376379
superRefine(
377380
refinement: (arg: Output, ctx: RefinementCtx) => unknown | Promise<unknown>

0 commit comments

Comments
 (0)