feat(client): Map Bytes to generic Uint8Array depending on TypeScript version#28139
Merged
jkomyno merged 2 commits intoprisma:mainfrom Oct 8, 2025
Merged
Conversation
…ript version Add a new runtime helper type `Bytes`, that either maps to `Uint8Array` or `Uint8Array<ArrayBuffer>`. Both `client-generator-ts` and `client-generator-js` now map `Bytes` to the new `runtime.Bytes` type. Fixes prisma#27854
9a9626b to
7c65520
Compare
jkomyno
approved these changes
Oct 1, 2025
Contributor
Author
|
I see this was approved and added to the 6.17.0 milestone, but 6.17.0 just released without this PR. If there is anything I can do to get this merged (or an alternative solution), please let me know 😊 |
Contributor
Hey there! Sorry, I was out sick for a couple of days and we forgot about merging this one on time. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a new runtime helper type
Bytes, that either maps toUint8ArrayorUint8Array<ArrayBuffer>. Bothclient-generator-tsandclient-generator-jsnow mapBytesto the newruntime.Bytestype.I verified these changes manually in a sandbox with different TypeScript versions, but I would be happy to add tests if I get some pointers where/how to test this.
For
client-generator-jsI followedPrisma.DecimalandPrisma.JsonXand added aPrisma.Bytes. Instead of exposing this asPrisma.Bytes, this could maybe just life internally in the generated client without being exported. I also exported it from theclient-generator-tsto align it withclient-generator-js, even though it is not used there (runtime.Bytesis used directly).Context
TypeScript 5.9 changed
ArrayBufferto be no longer a super type ofUint8Array<ArrayBufferLike>(src), which is the default forUint8Arraywithout generics. This makes it difficult to passBytesreceived from prisma to APIs that expectArrayBuffer.Uint8Arrayis generic since TypeScript 5.7 (src).Fixes #27854