Skip to content

feat(client): Map Bytes to generic Uint8Array depending on TypeScript version#28139

Merged
jkomyno merged 2 commits intoprisma:mainfrom
darthmaim:feature/bytes-generic-uint8array
Oct 8, 2025
Merged

feat(client): Map Bytes to generic Uint8Array depending on TypeScript version#28139
jkomyno merged 2 commits intoprisma:mainfrom
darthmaim:feature/bytes-generic-uint8array

Conversation

@darthmaim
Copy link
Copy Markdown
Contributor

@darthmaim darthmaim commented Sep 19, 2025

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.

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-js I followed Prisma.Decimal and Prisma.JsonX and added a Prisma.Bytes. Instead of exposing this as Prisma.Bytes, this could maybe just life internally in the generated client without being exported. I also exported it from the client-generator-ts to align it with client-generator-js, even though it is not used there (runtime.Bytes is used directly).

Context

TypeScript 5.9 changed ArrayBuffer to be no longer a super type of Uint8Array<ArrayBufferLike> (src), which is the default for Uint8Array without generics. This makes it difficult to pass Bytes received from prisma to APIs that expect ArrayBuffer.

Uint8Array is generic since TypeScript 5.7 (src).

Fixes #27854

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Sep 19, 2025

CLA assistant check
All committers have signed the CLA.

…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
@darthmaim darthmaim force-pushed the feature/bytes-generic-uint8array branch from 9a9626b to 7c65520 Compare September 19, 2025 15:46
@aqrln aqrln added this to the 6.17.0 milestone Sep 30, 2025
@darthmaim
Copy link
Copy Markdown
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 😊

@jkomyno jkomyno modified the milestones: 6.17.0, 6.18.0 Oct 8, 2025
@jkomyno jkomyno merged commit 1b99e2a into prisma:main Oct 8, 2025
810 of 812 checks passed
@jkomyno
Copy link
Copy Markdown
Contributor

jkomyno commented Oct 8, 2025

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 😊

Hey there! Sorry, I was out sick for a couple of days and we forgot about merging this one on time.

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.

[TypeScript 5.9] Change type of Bytes from Uint8Array to Uint8Array<ArrayBuffer>

4 participants