roblox-ts: Transpile property/method accesses that would be invalid Lua into bracket syntax
Solve the promise:andThen and Symbol.for macros in a more generic way, instead changing reserved Lua keyword accesses into bracket literal syntax.
Symbol["for"]
promise["then"](promise, ...) <-- need to do this special behavior for method syntax
Additionally when generating Lua from classes/otherwise, ensure that we do something like this:
t["then"] = function(self)
end
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 18 (5 by maintainers)
For Roblox-ts “built-in” names, I think all. For user created methods/variables/etc, just the keyword collisions. This could be more elegantly balanced if we carefully implemented Promise and perhaps the Run-time lib in TS.
Sure, we have precedent of doing something similar with generated variables elsewhere in the compiler (like
_0)But maybe allowing this is a bad idea to begin with: Classes created with TS that use reserved Lua keywords would lose the ability to inter-op with Lua effectively. But also, function calls can be expressions, so that could dramatically increase the complexity of compiled code.
For example,
foo(returnsAPromise().then(() => {}))