@@ -137,7 +137,7 @@ var LuaTranspiler = /** @class */ (function () {
137137 } ;
138138 LuaTranspiler . prototype . transpileNamespace = function ( node ) {
139139 // If phantom namespace just transpile the body as normal
140- if ( TSHelper_1 . TSHelper . isPhantom ( this . checker . getTypeAtLocation ( node ) ) )
140+ if ( TSHelper_1 . TSHelper . isPhantom ( this . checker . getTypeAtLocation ( node ) , this . checker ) )
141141 return this . transpileNode ( node . body ) ;
142142 var defName = this . definitionName ( node . name . text ) ;
143143 var result = this . indent + ( defName + " = {}\n" ) ;
@@ -151,7 +151,7 @@ var LuaTranspiler = /** @class */ (function () {
151151 var val = 0 ;
152152 var result = "" ;
153153 var type = this . checker . getTypeAtLocation ( node ) ;
154- var membersOnly = TSHelper_1 . TSHelper . isCompileMembersOnlyEnum ( type ) ;
154+ var membersOnly = TSHelper_1 . TSHelper . isCompileMembersOnlyEnum ( type , this . checker ) ;
155155 if ( ! membersOnly ) {
156156 var defName = this . definitionName ( node . name . escapedText ) ;
157157 result += this . indent + ( defName + "={}\n" ) ;
@@ -386,6 +386,12 @@ var LuaTranspiler = /** @class */ (function () {
386386 case ts . SyntaxKind . MinusEqualsToken :
387387 result = lhs + "=" + lhs + "-" + rhs ;
388388 break ;
389+ case ts . SyntaxKind . AsteriskEqualsToken :
390+ result = lhs + "=" + lhs + "*" + rhs ;
391+ break ;
392+ case ts . SyntaxKind . SlashEqualsToken :
393+ result = lhs + "=" + lhs + "/" + rhs ;
394+ break ;
389395 case ts . SyntaxKind . AmpersandAmpersandToken :
390396 result = lhs + " and " + rhs ;
391397 break ;
@@ -432,7 +438,7 @@ var LuaTranspiler = /** @class */ (function () {
432438 var condition = this . transpileExpression ( node . condition ) ;
433439 var val1 = this . transpileExpression ( node . whenTrue ) ;
434440 var val2 = this . transpileExpression ( node . whenFalse ) ;
435- return "TS_ITE(" + condition + ",function() return " + val1 + " end, function() return " + val2 + " end)" ;
441+ return "TS_ITE(" + condition + ",function() return " + val1 + " end,function() return " + val2 + " end)" ;
436442 } ;
437443 // Replace some missmatching operators
438444 LuaTranspiler . prototype . transpileOperator = function ( operator ) {
@@ -450,9 +456,9 @@ var LuaTranspiler = /** @class */ (function () {
450456 var operand = this . transpileExpression ( node . operand , true ) ;
451457 switch ( node . operator ) {
452458 case ts . SyntaxKind . PlusPlusToken :
453- return operand + " = " + operand + " + 1" ;
459+ return operand + "= " + operand + "+ 1" ;
454460 case ts . SyntaxKind . MinusMinusToken :
455- return operand + " = " + operand + " - 1" ;
461+ return operand + "= " + operand + "- 1" ;
456462 default :
457463 throw new TranspileError ( "Unsupported unary postfix: " + TSHelper_1 . TSHelper . enumName ( node . kind , ts . SyntaxKind ) , node ) ;
458464 }
@@ -461,9 +467,9 @@ var LuaTranspiler = /** @class */ (function () {
461467 var operand = this . transpileExpression ( node . operand , true ) ;
462468 switch ( node . operator ) {
463469 case ts . SyntaxKind . PlusPlusToken :
464- return operand + " = " + operand + " + 1" ;
470+ return operand + "= " + operand + "+ 1" ;
465471 case ts . SyntaxKind . MinusMinusToken :
466- return operand + " = " + operand + " - 1" ;
472+ return operand + "= " + operand + "- 1" ;
467473 case ts . SyntaxKind . ExclamationToken :
468474 return "not " + operand ;
469475 case ts . SyntaxKind . MinusToken :
@@ -584,7 +590,7 @@ var LuaTranspiler = /** @class */ (function () {
584590 return this . transpileArrayProperty ( node ) ;
585591 }
586592 // Do not output path for member only enums
587- if ( TSHelper_1 . TSHelper . isCompileMembersOnlyEnum ( type ) ) {
593+ if ( TSHelper_1 . TSHelper . isCompileMembersOnlyEnum ( type , this . checker ) ) {
588594 return property ;
589595 }
590596 var path = this . transpileExpression ( node . expression ) ;
@@ -717,16 +723,16 @@ var LuaTranspiler = /** @class */ (function () {
717723 if ( clause . token == ts . SyntaxKind . ExtendsKeyword ) {
718724 var superType = _this . checker . getTypeAtLocation ( clause . types [ 0 ] ) ;
719725 // Ignore purely abstract types (decorated with /** @PureAbstract */)
720- if ( ! TSHelper_1 . TSHelper . isPureAbstractClass ( superType ) ) {
726+ if ( ! TSHelper_1 . TSHelper . isPureAbstractClass ( superType , _this . checker ) ) {
721727 extendsType = clause . types [ 0 ] ;
722728 }
723- noClassOr = TSHelper_1 . TSHelper . hasCustomDecorator ( superType , "!NoClassOr" ) ;
729+ noClassOr = TSHelper_1 . TSHelper . hasCustomDecorator ( superType , _this . checker , "!NoClassOr" ) ;
724730 }
725731 } ) ;
726732 var className = node . name . escapedText ;
727733 var result = "" ;
728734 // Skip header if this is an extension class
729- var isExtension = TSHelper_1 . TSHelper . isExtensionClass ( this . checker . getTypeAtLocation ( node ) ) ;
735+ var isExtension = TSHelper_1 . TSHelper . isExtensionClass ( this . checker . getTypeAtLocation ( node ) , this . checker ) ;
730736 if ( ! isExtension ) {
731737 // Write class declaration
732738 var classOr = noClassOr ? "" : className + " or " ;
@@ -785,6 +791,12 @@ var LuaTranspiler = /** @class */ (function () {
785791 node . members . filter ( ts . isMethodDeclaration ) . forEach ( function ( method ) {
786792 result += _this . transpileMethodDeclaration ( method , className + "." ) ;
787793 } ) ;
794+ // Check if the class should be returned
795+ var isExport = node . modifiers && node . modifiers . some ( function ( _ ) { return _ . kind == ts . SyntaxKind . ExportKeyword ; } ) ;
796+ var isDefault = node . modifiers && node . modifiers . some ( function ( _ ) { return _ . kind == ts . SyntaxKind . DefaultKeyword ; } ) ;
797+ if ( isExport && isDefault ) {
798+ result += this . indent + ( "return " + className + "\n" ) ;
799+ }
788800 return result ;
789801 } ;
790802 LuaTranspiler . prototype . transpileConstructor = function ( node , className , instanceFields ) {
0 commit comments