Skip to content

base64/hex methods missing from Uint8Array #61695

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dontwanttothink opened this issue May 12, 2025 · 6 comments Β· May be fixed by #61696
Open

base64/hex methods missing from Uint8Array #61695

dontwanttothink opened this issue May 12, 2025 · 6 comments Β· May be fixed by #61696
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this
Milestone

Comments

@dontwanttothink
Copy link

dontwanttothink commented May 12, 2025

πŸ”Ž Search Terms

  • toBase64

πŸ•— Version & Regression Information

  • This is the behavior in v5.9.0-dev.20250512.

⏯ Playground Link

https://www.typescriptlang.org/play/?ts=5.9.0-dev.20250512#code/KoSwdgLgHAggTnAhgTwHQDM4HsC2AhRAZwFMA2AFgAoBKAKFElgRQ2xwAliAPG+8aeEjQAHbBCwRkw4qhIQAYmwIkKvBgOYixEqTLmLcnHnXVMhqURJ3TU45WSon+ZlpfGSb4ozSA

πŸ’» Code

Uint8Array.fromBase64()
Uint8Array.fromHex()
Uint8Array.prototype.setFromBase64()
Uint8Array.prototype.setFromHex()
Uint8Array.prototype.toBase64()
Uint8Array.prototype.toHex()

πŸ™ Actual behavior

Property XXX does not exist … errors in each case.

πŸ™‚ Expected behavior

Correct type definitions should exist.

Additional information about the issue

These features have been implemented by every major JavaScript engine except V8.

See:

See also:

@MartinJohns
Copy link
Contributor

I wouldn't say it's widely supported when basically the engine with over 90 % market does not support it.

@dontwanttothink
Copy link
Author

V8 does not have a market share of over 90%. TypeScript is also used for browser code.

@RyanCavanaugh
Copy link
Member

TypeScript is also used for browser code.

V8 is also Chrome and Edge's runtime, so it's a very big problem if it's not there.

@dontwanttothink
Copy link
Author

dontwanttothink commented May 12, 2025

Note that, in the case of DOM APIs, type definitions seem to be generated automatically once two major engine implementations exist. I don't see why this standard JavaScript feature should be different. (Isn't this also the point of having an 'ESNext' library?)

@dontwanttothink
Copy link
Author

Further note that Chromium is working on shipping: https://issues.chromium.org/issues/42204568. The omission in TypeScript will need to be fixed soon (and will definitely be). Representing UInt8Arrays as hexstrings is very common when working with modern web APIs (both server- and client-side) because they are frequent as return values and are otherwise difficult to serialize.

@RyanCavanaugh RyanCavanaugh added Bug A bug in TypeScript Help Wanted You can do this labels May 12, 2025
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone May 12, 2025
@RyanCavanaugh RyanCavanaugh added the Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript label May 12, 2025
dontwanttothink added a commit to dontwanttothink/TypeScript that referenced this issue May 13, 2025
@dontwanttothink
Copy link
Author

I submitted a PR for this issue: #61696

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants