Skip to content

Commit 4f1fd41

Browse files
committed
Return default export classes
1 parent d0c8e76 commit 4f1fd41

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

dist/Transpiler.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,12 @@ var LuaTranspiler = /** @class */ (function () {
784784
node.members.filter(ts.isMethodDeclaration).forEach(function (method) {
785785
result += _this.transpileMethodDeclaration(method, className + ".");
786786
});
787+
// Check if the class should be returned
788+
var isExport = node.modifiers && node.modifiers.some(function (_) { return _.kind == ts.SyntaxKind.ExportKeyword; });
789+
var isDefault = node.modifiers && node.modifiers.some(function (_) { return _.kind == ts.SyntaxKind.DefaultKeyword; });
790+
if (isExport && isDefault) {
791+
result += this.indent + ("return " + className + "\n");
792+
}
787793
return result;
788794
};
789795
LuaTranspiler.prototype.transpileConstructor = function (node, className, instanceFields) {

src/Transpiler.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,13 @@ export class LuaTranspiler {
852852
result += this.transpileMethodDeclaration(method, `${className}.`);
853853
});
854854

855+
// Check if the class should be returned
856+
const isExport = node.modifiers && node.modifiers.some(_ => _.kind == ts.SyntaxKind.ExportKeyword);
857+
const isDefault = node.modifiers && node.modifiers.some(_ => _.kind == ts.SyntaxKind.DefaultKeyword);
858+
if (isExport && isDefault) {
859+
result += this.indent + `return ${className}\n`;
860+
}
861+
855862
return result;
856863
}
857864

0 commit comments

Comments
 (0)