Skip to content

fs' readFile incompatible with TypeScript 5.9.2 #2914

Closed

Description

@samhinshaw

TypeScript 5.9.2 changed the default behavior of BufferSource in lib.dom.d.ts. Now, instead of accepting type BufferSource = ArrayBufferView | ArrayBuffer;, it accepts type BufferSource = ArrayBufferView<ArrayBuffer> | ArrayBuffer;. This manifests when attempting to use the result of a readFile call to construct a File:

Example:

const filePath = "./myfile.txt"
const fileData = await readFile(filePath));
const file = new File([fileData], "myfile.txt");

Error:

Type 'Uint8Array<ArrayBufferLike>' is not assignable to type 'BlobPart'.
  Type 'Uint8Array<ArrayBufferLike>' is not assignable to type 'ArrayBufferView<ArrayBuffer>'.
    Types of property 'buffer' are incompatible.
      Type 'ArrayBufferLike' is not assignable to type 'ArrayBuffer'.
        Type 'SharedArrayBuffer' is not assignable to type 'ArrayBuffer'.
          Types of property '[Symbol.toStringTag]' are incompatible.
            Type '"SharedArrayBuffer"' is not assignable to type '"ArrayBuffer"'.

Activity

  1. added
    plugin: fsIncludes former "fs-extra" and "fs-watch" plugins
    on Aug 13, 2025
  2. added a commit that references this issue on Aug 17, 2025
    515182a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    plugin: fsIncludes former "fs-extra" and "fs-watch" plugins

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions