Why \"Text" is compiled to $$Text

Hello everyone,
I work on a ReScript/React Design System, we expose many components for our users.
I try to export a module component named “Text” and the compiler transform (in JS) the module into “var $$Text = …”.
The problem is that I can’t import, in JS, the component with the name “Text”.

I find the same behavior with Boolean and String (https://rescript-lang.org/try?code=LYewJgrgNgpgBAFRgDwC5wLxwN4F8DcAUKJLHAEIgiwCGAdpjgceNPAMqoBOAlnQOaM8RFqXgAxKCBroswwqLZwAknVlMiQA)

Is “Text” a reserve keyword ?
I want to understand why the compiler build this :slight_smile:

Text is a global value in the DOM API, so we play safe here, since redefine the global value has a subtle semantics.

This is indeed not very nice in most cases, can you file an issue on github to remind to see if we can improve it in the future? thanks

1 Like

Thanks for the reply
I create the issue : https://github.com/rescript-lang/rescript-compiler/issues/5306
Hope your find an improvment soon :smiley:

Seems like the full list of “reserved” names can be found here.

1 Like