Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/LuaTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1322,9 +1322,12 @@ export class LuaTransformer {
this.currentNamespace = statement;

// Transform moduleblock to block and visit it
if (statement.body && ts.isModuleBlock(statement.body)) {
if (statement.body && (ts.isModuleBlock(statement.body) || ts.isModuleDeclaration(statement.body))) {
this.pushScope(ScopeType.Block, statement);
const statements = this.performHoisting(this.transformStatements(statement.body.statements));
let statements = ts.isModuleBlock(statement.body)
? this.transformStatements(statement.body.statements)
: this.transformModuleDeclaration(statement.body);
statements = this.performHoisting(statements);
this.popScope();
result.push(tstl.createDoStatement(statements));
}
Expand Down
9 changes: 9 additions & 0 deletions test/unit/modules.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,13 @@ export class LuaModuleTests {
// Assert
Expect(lua).toBe(``);
}

@Test("Nested module with dot in name")
public nestedModuleWithDotInName(): void {
const code =
`module a.b {
export const foo = "foo";
}`;
Expect(util.transpileAndExecute("return a.b.foo;", undefined, undefined, code)).toBe("foo");
}
}