Skip to content

fix!: specify type of backing buffer when Uint8Arrays are returned#335

Merged
achingbrain merged 10 commits into
masterfrom
fix/update-import-paths
May 7, 2026
Merged

fix!: specify type of backing buffer when Uint8Arrays are returned#335
achingbrain merged 10 commits into
masterfrom
fix/update-import-paths

Conversation

@achingbrain
Copy link
Copy Markdown
Member

@achingbrain achingbrain commented May 4, 2026

Since microsoft/TypeScript#59417 Uint8Arrays are generic so update the types here to be explicit about what backing buffer is used by the Uint8Array that is returned from operations, but be flexible enough to accept any type of backing buffer.

Upgrades aegir to update @types/node to 24.x (e.g. lts) and enables node.js type stripping to remove the need to build before testing.

  • Where Uint8Arrays are returned, ensure they are Uint8Array<ArrayBuffer>
  • Import from '.ts' files instead of '.js' where they exist

BREAKING CHANGE: Returned Uint8Arrays are now Uint8Array<ArrayBuffer>

Future-proofing against upcoming aegir upgrade that enables node.js
type stripping to remove the need to build before testing.
@achingbrain achingbrain changed the title fix: import from '.ts' files instead of '.js' where they exist fix: specify type of backing buffer when Uint8Arrays are returned May 4, 2026
Copy link
Copy Markdown
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, iiuc enables sync require() from CJS in Node 22+ which is welcome quality of life improvement

but i think should be marked as breaking change? (fix!: or feat!:) + also check two small (optional) nits below

Comment thread src/hashes/interface.ts Outdated
Comment thread src/bytes.ts Outdated
achingbrain and others added 2 commits May 5, 2026 15:22
@achingbrain achingbrain changed the title fix: specify type of backing buffer when Uint8Arrays are returned fix!: specify type of backing buffer when Uint8Arrays are returned May 5, 2026
@achingbrain
Copy link
Copy Markdown
Member Author

but i think should be marked as breaking change? (fix!: or feat!:)

I was hoping to avoid that since most code has historically assumed Uint8Array<ArrayBuffer> but you're right it'd be safer to release a major.

In which case I'd like to get #337 in too, if we merge them at the same time only one major version bump would occur.

@achingbrain achingbrain merged commit bac2da5 into master May 7, 2026
22 checks passed
@achingbrain achingbrain deleted the fix/update-import-paths branch May 7, 2026 05:49
github-actions Bot pushed a commit that referenced this pull request May 7, 2026
## [14.0.0](v13.4.2...v14.0.0) (2026-05-07)

### ⚠ BREAKING CHANGES

* all `Hasher`s are now `MultihashHasher<Code>`s
* Returned `Uint8Array`s are now `Uint8Array<ArrayBuffer>`

### Bug Fixes

* identity hash is SyncMultihashHasher<0> ([#337](#337)) ([9b5b12b](9b5b12b)), closes [#313](#313) [#314](#314)
* specify type of backing buffer when Uint8Arrays are returned ([#335](#335)) ([bac2da5](bac2da5))
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

🎉 This PR is included in version 14.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants