Skip to content

Commit 29ae00e

Browse files
authored
Merge pull request #127 from Perryvw/module-fix
Fixed module statement not adding module table
2 parents bbaf3ae + 5ee274a commit 29ae00e

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/Transpiler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export abstract class LuaTranspiler {
7171
public makeExport(name: string | ts.__String, node: ts.Node, dummy?: boolean): string {
7272
let result: string = "";
7373
if (node &&
74-
node.modifiers &&
74+
node.modifiers && this.isModule &&
7575
(ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Export)
7676
) {
7777
if (dummy) {

test/unit/modules.spec.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Expect, Test, TestCase } from "alsatian";
22
import * as ts from "typescript";
3-
import { LuaTarget, LuaTranspiler } from "../../src/Transpiler";
3+
44
import * as util from "../src/util";
55

66
export class LuaModuleTests {
@@ -34,4 +34,13 @@ export class LuaModuleTests {
3434
Expect(() => transpiler.transpileImport(mockDeclaration as ts.ImportDeclaration))
3535
.toThrowError(Error, "Unsupported import type.");
3636
}
37+
38+
@Test("Non-exported module")
39+
public nonExportedModule() {
40+
const lua = util.transpileString("module g { export function test() { return 3; } } return g.test();");
41+
42+
const result = util.executeLua(lua);
43+
44+
Expect(result).toBe(3);
45+
}
3746
}

0 commit comments

Comments
 (0)