zod 4.2.0-canary.20251016T223057 → 4.2.0-canary.20251017T221623

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.2.0-canary.20251016T223057",
3
+ "version": "4.2.0-canary.20251017T221623",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Colin McDonnell <zod@colinhacks.com>",
@@ -265,7 +265,6 @@ export const _ZodString: core.$constructor<_ZodString> = /*@__PURE__*/ core.$con
265
265
  inst.maxLength = bag.maximum ?? null;
266
266
 
267
267
  // validations
268
- // if (inst.regex) throw new Error("regex already defined");
269
268
  inst.regex = (...args) => inst.check(checks.regex(...args));
270
269
  inst.includes = (...args) => inst.check(checks.includes(...args));
271
270
  inst.startsWith = (...args) => inst.check(checks.startsWith(...args));
@@ -749,7 +749,7 @@ test("z.json", () => {
749
749
  test("z.promise", async () => {
750
750
  const a = z.promise(z.string());
751
751
  type a = z.output<typeof a>;
752
- expectTypeOf<a>().toEqualTypeOf<string>();
752
+ expectTypeOf<a>().toEqualTypeOf<Promise<string>>();
753
753
 
754
754
  expect(await z.safeParseAsync(a, Promise.resolve("hello"))).toMatchObject({
755
755
  success: true,
@@ -10,7 +10,7 @@ const promSchema = z.promise(
10
10
 
11
11
  test("promise inference", () => {
12
12
  type promSchemaType = z.infer<typeof promSchema>;
13
- expectTypeOf<promSchemaType>().toEqualTypeOf<{ name: string; age: number }>();
13
+ expectTypeOf<promSchemaType>().toEqualTypeOf<Promise<{ name: string; age: number }>>();
14
14
  });
15
15
 
16
16
  test("promise parsing success", async () => {
@@ -47,7 +47,7 @@ test("flat inference", () => {
47
47
  expectTypeOf<typeof readonlyNumberRecord._output>().toEqualTypeOf<Readonly<Record<string, number>>>();
48
48
  expectTypeOf<typeof readonlyObject._output>().toEqualTypeOf<{ readonly a: string; readonly 1: number }>();
49
49
  expectTypeOf<typeof readonlyEnum._output>().toEqualTypeOf<Readonly<testEnum>>();
50
- expectTypeOf<typeof readonlyPromise._output>().toEqualTypeOf<string>();
50
+ expectTypeOf<typeof readonlyPromise._output>().toEqualTypeOf<Promise<string>>();
51
51
  });
52
52
 
53
53
  // test("deep inference", () => {
@@ -4103,7 +4103,7 @@ export interface $ZodPromiseDef<T extends SomeType = $ZodType> extends $ZodTypeD
4103
4103
  }
4104
4104
 
4105
4105
  export interface $ZodPromiseInternals<T extends SomeType = $ZodType>
4106
- extends $ZodTypeInternals<core.output<T>, util.MaybeAsync<core.input<T>>> {
4106
+ extends $ZodTypeInternals<Promise<core.output<T>>, util.MaybeAsync<core.input<T>>> {
4107
4107
  def: $ZodPromiseDef<T>;
4108
4108
  isst: never;
4109
4109
  }
@@ -1,43 +1,5 @@
1
1
  import { expect, test } from "vitest";
2
- // import * as z from "zod/v4/core";
3
2
 
4
3
  test("z.function", () => {
5
4
  expect(true).toEqual(true);
6
5
  });
7
-
8
- // test("z.function", () => {
9
- // const a = z.function({
10
- // args: z.tuple([z.string()]),
11
- // returns: z.string(),
12
- // });
13
-
14
- // const myFunc = a.implement((name: string | number) => `Hello, ${name}!`);
15
-
16
- // expect(myFunc("world")).toEqual("Hello, world!");
17
- // expect(() => myFunc(123 as any)).toThrow();
18
-
19
- // // this won't run
20
- // () => {
21
- // // @ts-expect-error
22
- // const r = myFunc(123);
23
- // expectTypeOf(r).toEqualTypeOf<string>();
24
- // };
25
- // });
26
-
27
- // test("z.function async", async () => {
28
- // const b = z.function({
29
- // args: z.tuple([z.string()]).$check(async (_) => {}),
30
- // returns: z.string().$check(async (_) => {}),
31
- // });
32
- // const myFuncAsync = b.implementAsync(async (name) => `Hello, ${name}!`);
33
-
34
- // expect(await myFuncAsync("world")).toEqual("Hello, world!");
35
- // expect(myFuncAsync(123 as any)).rejects.toThrow();
36
-
37
- // // this won't run
38
- // () => {
39
- // // @ts-expect-error
40
- // const r = myFuncAsync(123);
41
- // expectTypeOf(r).toEqualTypeOf<Promise<string>>();
42
- // };
43
- // });
@@ -789,7 +789,7 @@ test("z.stringbool", () => {
789
789
  test("z.promise", async () => {
790
790
  const a = z.promise(z.string());
791
791
  type a = z.output<typeof a>;
792
- expectTypeOf<a>().toEqualTypeOf<string>();
792
+ expectTypeOf<a>().toEqualTypeOf<Promise<string>>();
793
793
 
794
794
  expect(await z.safeParseAsync(a, Promise.resolve("hello"))).toMatchObject({
795
795
  success: true,
@@ -208,7 +208,6 @@ exports._ZodString = core.$constructor("_ZodString", (inst, def) => {
208
208
  inst.minLength = bag.minimum ?? null;
209
209
  inst.maxLength = bag.maximum ?? null;
210
210
  // validations
211
- // if (inst.regex) throw new Error("regex already defined");
212
211
  inst.regex = (...args) => inst.check(checks.regex(...args));
213
212
  inst.includes = (...args) => inst.check(checks.includes(...args));
214
213
  inst.startsWith = (...args) => inst.check(checks.startsWith(...args));
@@ -91,7 +91,6 @@ export const _ZodString = /*@__PURE__*/ core.$constructor("_ZodString", (inst, d
91
91
  inst.minLength = bag.minimum ?? null;
92
92
  inst.maxLength = bag.maximum ?? null;
93
93
  // validations
94
- // if (inst.regex) throw new Error("regex already defined");
95
94
  inst.regex = (...args) => inst.check(checks.regex(...args));
96
95
  inst.includes = (...args) => inst.check(checks.includes(...args));
97
96
  inst.startsWith = (...args) => inst.check(checks.startsWith(...args));
@@ -1063,7 +1063,7 @@ export interface $ZodPromiseDef<T extends SomeType = $ZodType> extends $ZodTypeD
1063
1063
  type: "promise";
1064
1064
  innerType: T;
1065
1065
  }
1066
- export interface $ZodPromiseInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<T>, util.MaybeAsync<core.input<T>>> {
1066
+ export interface $ZodPromiseInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<Promise<core.output<T>>, util.MaybeAsync<core.input<T>>> {
1067
1067
  def: $ZodPromiseDef<T>;
1068
1068
  isst: never;
1069
1069
  }
@@ -1063,7 +1063,7 @@ export interface $ZodPromiseDef<T extends SomeType = $ZodType> extends $ZodTypeD
1063
1063
  type: "promise";
1064
1064
  innerType: T;
1065
1065
  }
1066
- export interface $ZodPromiseInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<T>, util.MaybeAsync<core.input<T>>> {
1066
+ export interface $ZodPromiseInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<Promise<core.output<T>>, util.MaybeAsync<core.input<T>>> {
1067
1067
  def: $ZodPromiseDef<T>;
1068
1068
  isst: never;
1069
1069
  }