Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScriptHelp WantedYou can do thisYou can do this
Milestone
Description
🔎 Search Terms
- toBase64
🕗 Version & Regression Information
- This is the behavior in v5.9.0-dev.20250512.
⏯ Playground Link
💻 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:
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array/toBase64#browser_compatibility (where it is marked, "Limited availability")
See also:
Reacted by James Prevett, Rúnar Berg Baugsson Sigríðarson, John Even Bjørnevik, sosoba and Artem Sapegin
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScriptHelp WantedYou can do thisYou can do this
Activity
MartinJohns commentedon May 12, 2025
I wouldn't say it's widely supported when basically the engine with over 90 % market does not support it.
dontwanttothink commentedon May 12, 2025
V8 does not have a market share of over 90%. TypeScript is also used for browser code.
RyanCavanaugh commentedon May 12, 2025
V8 is also Chrome and Edge's runtime, so it's a very big problem if it's not there.
dontwanttothink commentedon 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 commentedon May 12, 2025
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.Add type definitions for `Uint8Array` to/from base64 methods
dontwanttothink commentedon May 16, 2025
I submitted a PR for this issue: #61696
dontwanttothink commentedon Jul 1, 2025
This feature will be available across the stable channel of all major browsers by the end of next month. See #61696 (comment)