@@ -407,7 +407,7 @@ var LuaTranspiler = /** @class */ (function () {
407407 } ;
408408 LuaTranspiler . prototype . transpileNewExpression = function ( node ) {
409409 var name = this . transpileExpression ( node . expression ) ;
410- var params = this . transpileArguments ( node . arguments ) ;
410+ var params = this . transpileArguments ( node . arguments , ts . createTrue ( ) ) ;
411411 return name + ".new(" + params + ")" ;
412412 } ;
413413 LuaTranspiler . prototype . transpileCallExpression = function ( node ) {
@@ -431,7 +431,7 @@ var LuaTranspiler = /** @class */ (function () {
431431 if ( node . expression . kind == ts . SyntaxKind . SuperKeyword ) {
432432 var callPath_2 = this . transpileExpression ( node . expression ) ;
433433 var params_2 = this . transpileArguments ( node . arguments , ts . createNode ( ts . SyntaxKind . ThisKeyword ) ) ;
434- return "$ self.__base.constructor(" + params_2 + ")" ;
434+ return "self.__base.constructor(" + params_2 + ")" ;
435435 }
436436 var callPath = this . transpileExpression ( node . expression ) ;
437437 var params = this . transpileArguments ( node . arguments ) ;
@@ -579,20 +579,36 @@ var LuaTranspiler = /** @class */ (function () {
579579 // Transpile a class declaration
580580 LuaTranspiler . prototype . transpileClass = function ( node ) {
581581 var _this = this ;
582- // Figure out inheritance
583- var isExtension = node . heritageClauses && node . heritageClauses . length > 0 ;
584- var baseName = "" ;
585- if ( isExtension )
586- baseName = node . heritageClauses [ 0 ] . types [ 0 ] . expression . escapedText ;
582+ // Find extends class, ignore implements
583+ var extendsType ;
584+ if ( node . heritageClauses )
585+ node . heritageClauses . forEach ( function ( clause ) {
586+ if ( clause . token == ts . SyntaxKind . ExtendsKeyword ) {
587+ var superType = clause . types [ 0 ] ;
588+ // Ignore purely abstract types (decorated with /** @PureAbstract */)
589+ if ( ! TSHelper_1 . TSHelper . isPureAbstractClass ( _this . checker . getTypeAtLocation ( superType ) ) ) {
590+ extendsType = clause . types [ 0 ] ;
591+ }
592+ }
593+ } ) ;
587594 // Write class declaration
588595 var className = node . name . escapedText ;
589- var result = this . indent + ( className + " = " + className + " or {}\n" ) ;
596+ var result = "" ;
597+ if ( ! extendsType ) {
598+ result += this . indent + ( className + " = " + className + " or {}\n" ) ;
599+ }
600+ else {
601+ var baseName = extendsType . expression . escapedText ;
602+ result += this . indent + ( className + " = " + className + " or " + baseName + ".new()\n" ) ;
603+ }
590604 result += this . indent + ( className + ".__index = " + className + "\n" ) ;
591- if ( isExtension )
605+ if ( extendsType ) {
606+ var baseName = extendsType . expression . escapedText ;
592607 result += this . indent + ( className + ".__base = " + baseName + "\n" ) ;
593- result += this . indent + ( "function " + className + ".new(...)\n" ) ;
608+ }
609+ result += this . indent + ( "function " + className + ".new(construct, ...)\n" ) ;
594610 result += this . indent + ( " local instance = setmetatable({}, " + className + ")\n" ) ;
595- result += this . indent + ( " if " + className + ".constructor then " + className + ".constructor(instance, ...) end\n" ) ;
611+ result += this . indent + ( " if construct and " + className + ".constructor then " + className + ".constructor(instance, ...) end\n" ) ;
596612 result += this . indent + " return instance\n" ;
597613 result += this . indent + "end\n" ;
598614 // Get all properties with value
0 commit comments