diff --git a/src/Transpiler.ts b/src/Transpiler.ts index d60a32ca5..058055a4d 100644 --- a/src/Transpiler.ts +++ b/src/Transpiler.ts @@ -833,7 +833,7 @@ export class LuaTranspiler { public transpileNewExpression(node: ts.NewExpression): string { const name = this.transpileExpression(node.expression); - const params = this.transpileArguments(node.arguments, ts.createTrue()); + const params = node.arguments ? this.transpileArguments(node.arguments, ts.createTrue()) : "true"; return `${name}.new(${params})`; } diff --git a/test/translation/lua/classEmptyNew.lua b/test/translation/lua/classEmptyNew.lua new file mode 100644 index 000000000..b7d9462a7 --- /dev/null +++ b/test/translation/lua/classEmptyNew.lua @@ -0,0 +1,10 @@ +Test = Test or {} +Test.__index = Test +function Test.new(construct, ...) + local instance = setmetatable({}, Test) + if construct and Test.constructor then Test.constructor(instance, ...) end + return instance +end +function Test.constructor(self) +end +local t = Test.new(true) diff --git a/test/translation/ts/classEmptyNew.ts b/test/translation/ts/classEmptyNew.ts new file mode 100644 index 000000000..ffb7b1d59 --- /dev/null +++ b/test/translation/ts/classEmptyNew.ts @@ -0,0 +1,7 @@ +class Test { + constructor () { + + } +} + +let t = new Test;