Preserve UPPERCASE Constants in ReScript with Quoted Identifiers (Migration Win)

Hi all,

In the context of migrating JS/TS codebases, I wasted way too much time trying to figure out how to generate proper uppercase constants from ReScript code. This is especially painful during parity migrations where you want the output to match the original JS as closely as possible.

Turns out the solution is much simpler than I expected:

JavaScript

// constants.js (original)
const LIMIT = 10;

rescript

// constants.res
let \"LIMIT" = 10

That backslash-quoted identifier compiles exactly to var LIMIT = 10; in JS. No renaming, no workarounds, perfect 1:1 parity.

You are welcome :smile:.

See also: Use Illegal Identifier Names | ReScript Language Manual