Skip to content

Commit d6cd30d

Browse files
authored
fix #4973 (#4974)
1 parent dfae371 commit d6cd30d

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

packages/zod/src/v4/classic/tests/file.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { File as WebFile } from "@web-std/file";
22

3-
import { afterEach, beforeEach, expect, test } from "vitest";
3+
import { afterEach, beforeEach, expect, expectTypeOf, test } from "vitest";
44

55
import * as z from "zod/v4";
66

@@ -26,6 +26,10 @@ test("passing validations", () => {
2626
expect(() => mimeCheck.parse(new File([""], "test.txt", { type: "text/csv" }))).toThrow();
2727
});
2828

29+
test("types", () => {
30+
expectTypeOf(z.file().parse(new File([], "test.txt"))).toEqualTypeOf(new File([], "test.txt"));
31+
});
32+
2933
test("failing validations", () => {
3034
expect(minCheck.safeParse(new File(["1234"], "test.txt"))).toMatchInlineSnapshot(`
3135
{

packages/zod/src/v4/core/schemas.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2862,8 +2862,8 @@ export const $ZodLiteral: core.$constructor<$ZodLiteral> = /*@__PURE__*/ core.$c
28622862
type _File = typeof globalThis extends { File: infer F extends new (...args: any[]) => any } ? InstanceType<F> : {};
28632863
/** Do not reference this directly. */
28642864
export interface File extends _File {
2865-
type: string;
2866-
size: number;
2865+
readonly type: string;
2866+
readonly size: number;
28672867
}
28682868

28692869
export interface $ZodFileDef extends $ZodTypeDef {

0 commit comments

Comments
 (0)