Skip to content

Commit c22944b

Browse files
committed
Fix race condition
1 parent 91274c3 commit c22944b

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

‎packages/zod/src/v4/classic/tests/readonly.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ test("readonly and the get method", () => {
240240
expect(readonlyBigInt.parse(bigIntVal)).toEqual(bigIntVal);
241241
expect(readonlyBoolean.parse(true)).toEqual(true);
242242
const dateVal = new Date();
243-
expect(readonlyDate.parse(new Date())).toEqual(dateVal);
243+
expect(readonlyDate.parse(dateVal)).toEqual(dateVal);
244244
expect(readonlyUndefined.parse(undefined)).toEqual(undefined);
245245
expect(readonlyNull.parse(null)).toEqual(null);
246246
expect(readonlyAny.parse("whatever")).toEqual("whatever");

‎play.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
import { z } from "zod/v4";
22

3-
z.string().regex(/asdf/);
3+
// import { z } from "zod/v4";
44

5-
z.literal;
5+
export const elementInputSchema = z
6+
.discriminatedUnion("type", [
7+
z.object({
8+
type: z.literal("CONTAINER"),
9+
}),
10+
z.object({
11+
type: z.literal("SCREEN"),
12+
config: z.object({ x: z.number(), y: z.number() }),
13+
}),
14+
])
15+
.and(
16+
z.object({
17+
get children(): z.ZodOptional<z.ZodArray<typeof elementInputSchema>> {
18+
return z.array(elementInputSchema).optional();
19+
},
20+
})
21+
);
22+
23+
export type ElementInput = z.infer<typeof elementInputSchema>;

0 commit comments

Comments
 (0)