diff --git a/src/Transpiler.ts b/src/Transpiler.ts index 24b307447..8da56b848 100644 --- a/src/Transpiler.ts +++ b/src/Transpiler.ts @@ -71,7 +71,7 @@ export abstract class LuaTranspiler { public makeExport(name: string | ts.__String, node: ts.Node, dummy?: boolean): string { let result: string = ""; if (node && - node.modifiers && + node.modifiers && this.isModule && (ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Export) ) { if (dummy) { diff --git a/test/unit/modules.spec.ts b/test/unit/modules.spec.ts index a1de871be..60147b9f0 100644 --- a/test/unit/modules.spec.ts +++ b/test/unit/modules.spec.ts @@ -1,6 +1,6 @@ import { Expect, Test, TestCase } from "alsatian"; import * as ts from "typescript"; -import { LuaTarget, LuaTranspiler } from "../../src/Transpiler"; + import * as util from "../src/util"; export class LuaModuleTests { @@ -34,4 +34,13 @@ export class LuaModuleTests { Expect(() => transpiler.transpileImport(mockDeclaration as ts.ImportDeclaration)) .toThrowError(Error, "Unsupported import type."); } + + @Test("Non-exported module") + public nonExportedModule() { + const lua = util.transpileString("module g { export function test() { return 3; } } return g.test();"); + + const result = util.executeLua(lua); + + Expect(result).toBe(3); + } }