@@ -4477,7 +4477,8 @@ export class LuaTransformer {
44774477 }
44784478
44794479 if ( decorators . has ( DecoratorKind . LuaTable ) ) {
4480- return this . transformLuaTableProperty ( expression ) ;
4480+ const [ luaTable ] = this . parseLuaTableExpression ( expression ) ;
4481+ return luaTable ;
44814482 }
44824483
44834484 // Catch math expressions
@@ -4620,17 +4621,21 @@ export class LuaTransformer {
46204621 }
46214622 }
46224623
4623- protected transformLuaTableProperty ( node : ts . PropertyAccessExpression ) : tstl . Expression {
4624- switch ( node . name . text ) {
4624+ protected parseLuaTableExpression ( node : ts . PropertyAccessExpression ) : [ tstl . Expression , string ] {
4625+ const methodName = node . name . text ;
4626+ switch ( methodName ) {
46254627 case "set" :
4626- return this . transformExpression ( node . expression ) ;
4627- case "get" :
4628- return this . transformExpression ( node . expression ) ;
4629- case "length" :
4630- const propertyAccessExpression = this . transformExpression ( node . expression ) ;
4631- return tstl . createUnaryExpression ( propertyAccessExpression , tstl . SyntaxKind . LengthOperator , node ) ;
4632- default :
4633- throw TSTLErrors . UnsupportedProperty ( "LuaTable" , node . name . text , node ) ;
4628+ case "get" : {
4629+ return [ this . transformExpression ( node . expression ) , methodName ] ;
4630+ }
4631+ case "length" : {
4632+ const luaTable = this . transformExpression ( node . expression ) ;
4633+ const unaryExpression = tstl . createUnaryExpression ( luaTable , tstl . SyntaxKind . LengthOperator , node ) ;
4634+ return [ unaryExpression , methodName ] ;
4635+ }
4636+ default : {
4637+ throw TSTLErrors . UnsupportedProperty ( "LuaTable" , methodName , node ) ;
4638+ }
46344639 }
46354640 }
46364641
0 commit comments