Fix namespace and module resulting in invalid Lua when modified with … · root-cli/TypeScriptToLua@b26dac0 · GitHub
Skip to content

Commit b26dac0

Browse files
authored
Fix namespace and module resulting in invalid Lua when modified with TS transformer plugin (TypeScriptToLua#1014)
* Failing test * Fixed bug TypeScriptToLua#1013 * Fix prettier * Switched transformer plugin to TS instead of JS
1 parent a617faf commit b26dac0

3 files changed

Lines changed: 36 additions & 1 deletion

File tree

‎src/transformation/visitors/namespace.ts‎

Lines changed: 1 addition & 1 deletion

‎test/transpile/plugins/plugins.spec.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,23 @@ test("statement comments", () => {
4040
.setOptions({ luaPlugins: [{ name: path.join(__dirname, "add-comments.ts") }] })
4141
.expectLuaToMatchSnapshot();
4242
});
43+
44+
// https://github.com/TypeScriptToLua/TypeScriptToLua/issues/1013
45+
test.each(["namespace", "module"])("%s with TS transformer plugin", moduleOrNamespace => {
46+
util.testModule`
47+
import { ns } from "module";
48+
export const result = ns.returnsBool();
49+
`
50+
.addExtraFile(
51+
"module.ts",
52+
`
53+
export ${moduleOrNamespace} ns {
54+
export function returnsBool() {
55+
return false;
56+
}
57+
}
58+
`
59+
)
60+
.setOptions({ plugins: [{ transform: path.join(__dirname, "transformer-plugin.ts") }] })
61+
.expectNoExecutionError();
62+
});
Lines changed: 15 additions & 0 deletions

0 commit comments

Comments
 (0)