Why rescript escapes string by default?

For example:
would be compiled into:
and would display on page like:
After walking through the docs I found that I can use backtick string to avoid escaping, but I’m curious why is this escaping happening at the first place?

Edit: I see the team is working on double-quote strings to make it behave like backtick strings, but I still wonder why it was designed like this.

Hey! This is currently actively being worked on and will be fixed in the next release. If you’re curious about the technical details, you can follow along here: Unicode support by IwanKaramazow · Pull Request #433 · rescript-lang/syntax · GitHub


Thanks for the information! So if I understand correctly, the escaping is happening because rescript compiler treats source code as an ASCII characters stream?

Indeed, string literals are currently passing through some compiler code that escapes non-ascii content.

1 Like

OK, thanks for the explanation again!