-
Notifications
You must be signed in to change notification settings - Fork 8
Suggestion: add local aliasing for this #2
Comments
Could you add an example with an anon. function where it fails? |
Currently it doesn't seem to support properly, but here's a simple example:
The expected output for that
Otherwise when calling |
+1 on this proposal, although perhaps the aliased name should be underscored prefixed (e.g. "var _this = this;") |
Not really, it may make sense using in javascript but in a translator it's better to use the method receiver instead. You need the method receiver anyway so renaming the receiver to "this" in javascript adds nothing useful. Alternative of using the same variable name from the method receiver means that the problem basically disappears and it probably will make translation simpler. |
Sorry, I didn't notice that your example used t as the receiver. Yes, given that Go has explicit receiver identifiers then go2js can safely use that. |
This test
Currently translates to:
It would be probably better to translate into:
If you are at some point doing anon. functions then handling of this can get quite complicated otherwise.
The text was updated successfully, but these errors were encountered: