String constant generation for C is wrong. It should be<p><pre><code> const char X[] = "This string cannot be reassigned.";
</code></pre>
instead of<p><pre><code> const char *X = "This string CAN be reassigned";
</code></pre>
In the second case, you can do<p><pre><code> X = "Another value";
</code></pre>
X wouldn't be constant, but only the value it points to. Also, it costs sizeof(char *) more memory than the actual string contents.
This might make sense for "big" projects, with already several languages and an important need. Else it's not obvious if the burden of having yet another dependency has a favorable benefit-cost result.<p>In other words, the danger of "now you have two problems" should be considered. <a href="http://regex.info/blog/2006-09-15/247" rel="nofollow">http://regex.info/blog/2006-09-15/247</a>
Interesting idea, I would suggest looking into TypeScript enum support as well as it is a different syntax than the JS object based variant (the const string definition can be shared)<p><a href="https://www.typescriptlang.org/docs/handbook/enums.html" rel="nofollow">https://www.typescriptlang.org/docs/handbook/enums.html</a><p>Edit: from the image it looks like you're using some non standard formatting for the JS output, using Prettier may be more standard - <a href="https://prettier.io" rel="nofollow">https://prettier.io</a>
To the OP, I’m just curious what was the problem you were facing that inspired this project?<p>I haven’t run into a scenario where I would use something like this before