-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
String Key for Object Property #126
Comments
GorillaScript currently doesn't differentiate the two types of access, they're seen as equivalent and thus compile to the smallest possible representation. I'm not sure if I want to introduce the extra complexity at this time for something that won't work in all cases. If you use a property, there's no way of converting This seems like a downside of the Closure Compiler. Surely it would be able to know that constant string access is equivalent to dot access. |
I'm not sure I understand the middle paragraph of your comment. I think I'm asking for more transpiled output to be quoted. So things that are already quoted would stay quoted. But I'm suggesting/requesting that also properties (I'm just talking about simple gs/js object properties, not the special gorillascript property syntax) that are keyed with single quoted bracket notation in gorillascipt (e.g. Is your middle paragraph relevant in that scenario? Or am I hopelessly confused? |
It is relevant because there's no way to make sure that every non-quoted part stays non-quoted nor should one expect that every quoted part remain quoted. Adding such functionality would require an overhaul of the internal |
Okay. Thanks. |
As far as I can tell, there's no convenient way to ensure that gorillascript's output javascript keys a property via string.
transpiles to
I would think that 'fred' and 'corge' at least should retain string keys (i.e. transpile to (... ,"fred": "fred", ...) and (foo["corge"] = "corge";)) for the sake of consistency with 'plugh thud' and 'grault garply'.
At least one instance where this matters is when compiling with the Google Closure Compiler. It treats string keys differently from dotted access. It will freely rename dotted access (e.g. foo.bar to x.y) but keeps string keys intact (e.g. foo["bar"] to x["bar"]).
The text was updated successfully, but these errors were encountered: