diff --git a/test/index.test.js b/test/index.test.js index 1b47d649a..8b7319956 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -210,3 +210,31 @@ test("should not throw on yield new line when stripped", (t) => { const result = vm.runInContext(code, vm.createContext()); assert.strictEqual(result, 5); }); + +test("empty namespaces should be supported", (t) => { + const tests = [ + "namespace Empty {}", + `namespace TypeOnly { + type A = string; + + export type B = A | number; + + export interface I {} + + export namespace Inner { + export type C = B; + } + }`, + `namespace My.Internal.Types { + export type Foo = number; + }`, + `namespace With.Imports { + import Types = My.Internal.Types; + export type Foo = Types.Foo; + }`, + ]; + for(const input of tests) { + const { code } = transformSync(input); + assert.strictEqual(code, "".repeat(input.length)); + } +});