Skip to content

z.core.File is incompatible with globalThis.File type #4973

@ahrjarrett

Description

@ahrjarrett

It looks like z.core.File changes added in v4.0.6 are not compatible with globalThis.File.

Looks like it's because the size and type properties in z.core.File are mutable, but are readonly in globalThis.File.

Repro

import { expectTypeOf, test } from 'vitest'
import * as z from 'zod'

test('repro', () => {
  const file = new File([], 'test.txt')
  expectTypeOf(z.file().parse(file)).toEqualTypeOf(file)
  //                                               𐙘__𐙘 not equal because `size` and `type` are mutable
})

Should be a quick fix, will open a PR in a few

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions