zod 4.1.0-canary.20250710T223408 → 4.1.0-canary.20250711T200924

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zod",
3
- "version": "4.1.0-canary.20250710T223408",
3
+ "version": "4.1.0-canary.20250711T200924",
4
4
  "type": "module",
5
5
  "author": "Colin McDonnell <zod@colinhacks.com>",
6
6
  "description": "TypeScript-first schema declaration and validation library with static type inference",
@@ -1224,6 +1224,7 @@ export interface ZodDiscriminatedUnion<Options extends readonly core.SomeType[]
1224
1224
  extends ZodUnion<Options>,
1225
1225
  core.$ZodDiscriminatedUnion<Options> {
1226
1226
  _zod: core.$ZodDiscriminatedUnionInternals<Options>;
1227
+ def: core.$ZodDiscriminatedUnionDef<Options>;
1227
1228
  }
1228
1229
  export const ZodDiscriminatedUnion: core.$constructor<ZodDiscriminatedUnion> = /*@__PURE__*/ core.$constructor(
1229
1230
  "ZodDiscriminatedUnion",
@@ -1,6 +1,5 @@
1
1
  import { expect, expectTypeOf, test } from "vitest";
2
2
  import { z } from "zod/v4";
3
- import type { util } from "zod/v4/core";
4
3
 
5
4
  test("basic catch", () => {
6
5
  expect(z.string().catch("default").parse(undefined)).toBe("default");
@@ -45,7 +44,7 @@ test("catch with transform", () => {
45
44
  expect(stringWithDefault.unwrap().out).toBeInstanceOf(z.ZodTransform);
46
45
 
47
46
  type inp = z.input<typeof stringWithDefault>;
48
- expectTypeOf<inp>().toEqualTypeOf<string | util.Whatever>();
47
+ expectTypeOf<inp>().toEqualTypeOf<string>();
49
48
  type out = z.output<typeof stringWithDefault>;
50
49
  expectTypeOf<out>().toEqualTypeOf<string>();
51
50
  });
@@ -59,7 +58,7 @@ test("catch on existing optional", () => {
59
58
  expect(stringWithDefault.unwrap().unwrap()).toBeInstanceOf(z.ZodString);
60
59
 
61
60
  type inp = z.input<typeof stringWithDefault>;
62
- expectTypeOf<inp>().toEqualTypeOf<string | undefined | util.Whatever>();
61
+ expectTypeOf<inp>().toEqualTypeOf<string | undefined>();
63
62
  type out = z.output<typeof stringWithDefault>;
64
63
  expectTypeOf<out>().toEqualTypeOf<string | undefined>();
65
64
  });
@@ -68,7 +67,7 @@ test("optional on catch", () => {
68
67
  const stringWithDefault = z.string().catch("asdf").optional();
69
68
 
70
69
  type inp = z.input<typeof stringWithDefault>;
71
- expectTypeOf<inp>().toEqualTypeOf<string | util.Whatever>();
70
+ expectTypeOf<inp>().toEqualTypeOf<string | undefined>();
72
71
  type out = z.output<typeof stringWithDefault>;
73
72
  expectTypeOf<out>().toEqualTypeOf<string | undefined>();
74
73
  });
@@ -102,7 +101,7 @@ test("nested", () => {
102
101
  inner: "asdf",
103
102
  });
104
103
  type input = z.input<typeof outer>;
105
- expectTypeOf<input>().toEqualTypeOf<{ inner: string | util.Whatever } | util.Whatever>();
104
+ expectTypeOf<input>().toEqualTypeOf<{ inner: string }>();
106
105
  type out = z.output<typeof outer>;
107
106
 
108
107
  expectTypeOf<out>().toEqualTypeOf<{ inner: string }>();
@@ -646,3 +646,15 @@ test("pipes", () => {
646
646
  v: 2,
647
647
  });
648
648
  });
649
+
650
+ test("def", () => {
651
+ const schema = z.discriminatedUnion(
652
+ "type",
653
+ [z.object({ type: z.literal("play") }), z.object({ type: z.literal("pause") })],
654
+ { unionFallback: true }
655
+ );
656
+
657
+ expect(schema.def).toBeDefined();
658
+ expect(schema.def.discriminator).toEqual("type");
659
+ expect(schema.def.unionFallback).toEqual(true);
660
+ });
@@ -3315,11 +3315,8 @@ export interface $ZodCatchDef<T extends SomeType = $ZodType> extends $ZodTypeDef
3315
3315
  }
3316
3316
 
3317
3317
  export interface $ZodCatchInternals<T extends SomeType = $ZodType>
3318
- extends $ZodTypeInternals<core.output<T>, core.input<T> | util.Whatever> {
3318
+ extends $ZodTypeInternals<core.output<T>, core.input<T>> {
3319
3319
  def: $ZodCatchDef<T>;
3320
- // qin: T["_zod"]["qin"];
3321
- // qout: T["_zod"]["qout"];
3322
-
3323
3320
  optin: T["_zod"]["optin"];
3324
3321
  optout: T["_zod"]["optout"];
3325
3322
  isst: never;
@@ -1,5 +1,5 @@
1
1
  export const version = {
2
2
  major: 4,
3
3
  minor: 0,
4
- patch: 4 as number,
4
+ patch: 5 as number,
5
5
  } as const;
@@ -446,6 +446,7 @@ export declare const ZodUnion: core.$constructor<ZodUnion>;
446
446
  export declare function union<const T extends readonly core.SomeType[]>(options: T, params?: string | core.$ZodUnionParams): ZodUnion<T>;
447
447
  export interface ZodDiscriminatedUnion<Options extends readonly core.SomeType[] = readonly core.$ZodType[]> extends ZodUnion<Options>, core.$ZodDiscriminatedUnion<Options> {
448
448
  _zod: core.$ZodDiscriminatedUnionInternals<Options>;
449
+ def: core.$ZodDiscriminatedUnionDef<Options>;
449
450
  }
450
451
  export declare const ZodDiscriminatedUnion: core.$constructor<ZodDiscriminatedUnion>;
451
452
  export declare function discriminatedUnion<Types extends readonly [core.$ZodTypeDiscriminable, ...core.$ZodTypeDiscriminable[]]>(discriminator: string, options: Types, params?: string | core.$ZodDiscriminatedUnionParams): ZodDiscriminatedUnion<Types>;
@@ -446,6 +446,7 @@ export declare const ZodUnion: core.$constructor<ZodUnion>;
446
446
  export declare function union<const T extends readonly core.SomeType[]>(options: T, params?: string | core.$ZodUnionParams): ZodUnion<T>;
447
447
  export interface ZodDiscriminatedUnion<Options extends readonly core.SomeType[] = readonly core.$ZodType[]> extends ZodUnion<Options>, core.$ZodDiscriminatedUnion<Options> {
448
448
  _zod: core.$ZodDiscriminatedUnionInternals<Options>;
449
+ def: core.$ZodDiscriminatedUnionDef<Options>;
449
450
  }
450
451
  export declare const ZodDiscriminatedUnion: core.$constructor<ZodDiscriminatedUnion>;
451
452
  export declare function discriminatedUnion<Types extends readonly [core.$ZodTypeDiscriminable, ...core.$ZodTypeDiscriminable[]]>(discriminator: string, options: Types, params?: string | core.$ZodDiscriminatedUnionParams): ZodDiscriminatedUnion<Types>;
@@ -902,7 +902,7 @@ export interface $ZodCatchDef<T extends SomeType = $ZodType> extends $ZodTypeDef
902
902
  innerType: T;
903
903
  catchValue: (ctx: $ZodCatchCtx) => unknown;
904
904
  }
905
- export interface $ZodCatchInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<T>, core.input<T> | util.Whatever> {
905
+ export interface $ZodCatchInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<T>, core.input<T>> {
906
906
  def: $ZodCatchDef<T>;
907
907
  optin: T["_zod"]["optin"];
908
908
  optout: T["_zod"]["optout"];
@@ -902,7 +902,7 @@ export interface $ZodCatchDef<T extends SomeType = $ZodType> extends $ZodTypeDef
902
902
  innerType: T;
903
903
  catchValue: (ctx: $ZodCatchCtx) => unknown;
904
904
  }
905
- export interface $ZodCatchInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<T>, core.input<T> | util.Whatever> {
905
+ export interface $ZodCatchInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<T>, core.input<T>> {
906
906
  def: $ZodCatchDef<T>;
907
907
  optin: T["_zod"]["optin"];
908
908
  optout: T["_zod"]["optout"];
@@ -4,5 +4,5 @@ exports.version = void 0;
4
4
  exports.version = {
5
5
  major: 4,
6
6
  minor: 0,
7
- patch: 4,
7
+ patch: 5,
8
8
  };
@@ -1,5 +1,5 @@
1
1
  export const version = {
2
2
  major: 4,
3
3
  minor: 0,
4
- patch: 4,
4
+ patch: 5,
5
5
  };