Mark a private variable as used to prevent compiler from removing it

Here’s a code example:
https://rescript-lang.org/try?code=KTAOCcEsDcEMBcCmAKANo+ACCMGIGqziYC8mARAEZHkCUAUOljnEoeAGLgD2AtgEqwA7qUzBww5ORZ52dIA
How can I mark the privateVar as used so that it can be accessed from the %raw()?

1 Like

Interesting question. This isn’t an answer, but you get the same behavior (playground) if you shadow the original binding that you get in your example that uses private.

Edit: Also, if you make it private with an explicit module interface…

The recommended practice is make your raw a self contained function, and pass environments though arguments. Raw is pretty unsafe now, you don’t want to make it even more dangerous.