TypeScript: `ts.convertToBase64` does not handle emojis
Bug Report
> ts.convertToBase64("📣❓")
'7aC97bOj4p2T'
> Buffer.from("📣❓").toString("base64")
'8J+To+Kdkw=='
🔎 Search Terms
- ts.convertToBase64
- emojis
🕗 Version & Regression Information
Probably a long time.
⏯ Playground Link
N/A
💻 Code
ts.convertToBase64("📣❓")
🙁 Actual behavior
7aC97bOj4p2T
🙂 Expected behavior
8J+To+Kdkw==
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 1
- Comments: 16 (13 by maintainers)
Ah, cool; just wanted to make sure that you weren’t runtime patching and got surprised when 5.0 caused that to throw (since ESM exports can’t be modified externally, bundler or not).
Aside, but, if you are already using a fork, hopefully TS is a little more buildable for your uses now with some modification; you should be able to get pure ESM out of it. Might allow some tree shaking, but, probably not too much yet.
Please do send issues for APIs you think should be public; we already made public quite a few others in 5.0.
I opened https://github.com/denoland/deno/pull/17862 to remove its use.
Yeah, don’t worry about Deno too much because I can work around the TS codebase ok then hopefully over time can work on getting anything upstreamed. (In ts-morph though I’d rather not have to modify the ts source… I have this file with all the internal stuff I use: https://github.com/dsherret/ts-morph/blob/latest/packages/common/src/typescript/tsInternal.ts)
I’m looking for everyone who’s patching typescript in prep for TS 5.0 (where that sort of thing breaks), and found this issue via deno’s code.
@dsherret Can you instead provide
base64encode
on the host instead, thus avoiding the patch? Or are there calls which somehow don’t use the host?Gotcha, we can make the fallback implementation as slow as needed