Skip to content

Commit e736652

Browse files
authored
Merge pull request #66 from Perryvw/import-export-for-extension-classes
Added dummy exports for Extension classes
2 parents d9c4f83 + 2810962 commit e736652

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/Transpiler.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,21 @@ export class LuaTranspiler {
8585
"local " : ""
8686
}
8787

88-
makeExport(name: string | ts.__String, node: ts.Node): string {
88+
makeExport(name: string | ts.__String, node: ts.Node, dummy?: boolean): string {
8989
let result: string = "";
9090
if (node && node.modifiers && (ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Export)) {
91-
result = this.indent + `exports.${this.definitionName(name)} = ${name}\n`;
91+
if (dummy) {
92+
result = this.indent + `exports.${this.definitionName(name)} = {}\n`;
93+
} else {
94+
result = this.indent + `exports.${this.definitionName(name)} = ${name}\n`;
95+
}
9296
}
9397
if (this.namespace.length !== 0 && !ts.isModuleDeclaration(node)) {
94-
result += this.indent + `${this.definitionName(name)} = ${name}\n`;
98+
if (dummy) {
99+
result += this.indent + `${this.definitionName(name)} = {}\n`;
100+
} else {
101+
result += this.indent + `${this.definitionName(name)} = ${name}\n`;
102+
}
95103
}
96104
return result;
97105
}
@@ -1150,6 +1158,8 @@ export class LuaTranspiler {
11501158
result += this.indent + ` return instance\n`;
11511159
result += this.indent + `end\n`;
11521160
} else {
1161+
// export empty table
1162+
result += this.makeExport(className, node, true);
11531163
// Overwrite the original className with the class we are overriding for extensions
11541164
if (extendsType) {
11551165
className = <string>(<ts.Identifier>extendsType.expression).escapedText;

0 commit comments

Comments
 (0)