Skip to content

Fix TypeScript 5.9 build failures due to stricter ArrayBufferView generics#852

Draft
Copilot wants to merge 2 commits intodependabot/npm_and_yarn/npm-1cfa4b564dfrom
copilot/sub-pr-848
Draft

Fix TypeScript 5.9 build failures due to stricter ArrayBufferView generics#852
Copilot wants to merge 2 commits intodependabot/npm_and_yarn/npm-1cfa4b564dfrom
copilot/sub-pr-848

Conversation

Copy link
Contributor

Copilot AI commented Mar 5, 2026

TypeScript 5.9 made ArrayBufferView and Buffer generic with ArrayBufferLike as the default type parameter, while simultaneously tightening DOM types so BufferSource = ArrayBufferView<ArrayBuffer> | ArrayBuffer. This broke the build because SliceType used the unparameterized ArrayBufferView (now ArrayBufferView<ArrayBufferLike>), which is no longer assignable to BodyInit or XMLHttpRequestBodyInit.

Type annotation fixes

  • lib/options.ts: SliceType: ArrayBufferViewArrayBufferView<ArrayBuffer>
  • lib/sources/ArrayBufferViewFileSource.ts: _view field and constructor param: ArrayBufferViewArrayBufferView<ArrayBuffer>
  • lib/node/sources/NodeStreamFileSource.ts: returnBuffer local type: Buffer & { size?: number }Buffer<ArrayBuffer> & { size?: number }
  • lib/cordova/readAsByteArray.ts: Return type: Promise<Uint8Array>Promise<Uint8Array<ArrayBuffer>>

SharedArrayBuffer handling in commonFileReader.ts

Previously, SharedArrayBuffer-backed views and SharedArrayBuffer instances were silently accepted and would only fail at runtime when the HTTP stack tried to send them (browser APIs reject SharedArrayBuffer). Replaced unsafe type assertions with explicit runtime checks:

if (ArrayBuffer.isView(input)) {
  if (typeof SharedArrayBuffer !== 'undefined' && input.buffer instanceof SharedArrayBuffer) {
    throw new Error('tus: SharedArrayBuffer-backed views are not supported for uploads')
  }
  return new ArrayBufferViewFileSource(input as ArrayBufferView<ArrayBuffer>)
}

if (input instanceof ArrayBuffer) {
  return new ArrayBufferViewFileSource(new DataView(input))
}

if (typeof SharedArrayBuffer !== 'undefined' && input instanceof SharedArrayBuffer) {
  throw new Error('tus: SharedArrayBuffer is not supported for uploads')
}

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: Acconut <1375043+Acconut@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 5, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • tusd.tusdemo.net
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/tus-js-client/tus-js-client/node_modules/.bin/jasmine test/spec/node-index.js (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/tus-js-client/tus-js-client/node_modules/.bin/jasmine test/spec/node-index.js git tsc :&#34;module&#34;}&#39; &gt; lib.esm/package.json --global /usr/local/sbin/git (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Bump npm group across directory with 7 updates Fix TypeScript 5.9 build failures due to stricter ArrayBufferView generics Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants