Skip to content

Commit 21c11bc

Browse files
committed
emit namespace keyword
1 parent 8e203e7 commit 21c11bc

File tree

5 files changed

+10
-27
lines changed

5 files changed

+10
-27
lines changed

internal/transformers/declarations/transform.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,10 +1166,7 @@ func (tx *DeclarationTransformer) transformFunctionDeclaration(input *ast.Functi
11661166

11671167
parent := core.FirstOrNil(props)
11681168
if parent != nil {
1169-
declarationData.Symbol = &ast.Symbol{
1170-
Name: parent.Name,
1171-
Flags: ast.SymbolFlagsNamespaceModule,
1172-
}
1169+
declarationData.Symbol = parent
11731170
}
11741171

11751172
symbolTable := make(ast.SymbolTable, len(props))
@@ -1309,7 +1306,7 @@ func (tx *DeclarationTransformer) transformFunctionDeclaration(input *ast.Functi
13091306
updatedNamespaceDeclaration := tx.Factory().UpdateModuleDeclaration(
13101307
namespaceDeclaration.AsModuleDeclaration(),
13111308
modifiers,
1312-
namespaceDeclaration.Kind,
1309+
namespaceDeclaration.AsModuleDeclaration().Keyword,
13131310
namespaceDeclaration.Name(),
13141311
namespaceDeclaration.Body(),
13151312
)

testdata/baselines/reference/submodule/compiler/declarationEmitDefaultExportWithStaticAssignment.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export declare class Foo {
8383
}
8484
//// [index1.d.ts]
8585
declare function Example(): void;
86-
declare module Example {
86+
declare namespace Example {
8787
var Foo: typeof import("./foo").Foo;
8888
}
8989
export default Example;
@@ -92,7 +92,7 @@ export {};
9292
import { Foo } from './foo';
9393
export { Foo };
9494
declare function Example(): void;
95-
declare module Example {
95+
declare namespace Example {
9696
var Foo: typeof import("./foo").Foo;
9797
}
9898
export default Example;
@@ -101,7 +101,7 @@ export {};
101101
export declare class Bar {
102102
}
103103
declare function Example(): void;
104-
declare module Example {
104+
declare namespace Example {
105105
var Bar: typeof import("./index3").Bar;
106106
}
107107
export default Example;

testdata/baselines/reference/submodule/compiler/declarationEmitDefaultExportWithStaticAssignment.js.diff

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,23 @@
1818
Object.defineProperty(exports, "Foo", { enumerable: true, get: function () { return foo_1.Foo; } });
1919
function Example() { }
2020
Example.Foo = foo_1.Foo;
21-
@@= skipped -32, +32 lines =@@
22-
}
23-
//// [index1.d.ts]
24-
declare function Example(): void;
25-
-declare namespace Example {
26-
+declare module Example {
21+
@@= skipped -36, +36 lines =@@
2722
var Foo: typeof import("./foo").Foo;
2823
}
2924
export default Example;
3025
+export {};
3126
//// [index2.d.ts]
3227
import { Foo } from './foo';
3328
export { Foo };
34-
declare function Example(): void;
35-
-declare namespace Example {
36-
+declare module Example {
29+
@@= skipped -8, +9 lines =@@
3730
var Foo: typeof import("./foo").Foo;
3831
}
3932
export default Example;
4033
+export {};
4134
//// [index3.d.ts]
4235
export declare class Bar {
4336
}
44-
declare function Example(): void;
45-
-declare namespace Example {
46-
+declare module Example {
37+
@@= skipped -8, +9 lines =@@
4738
var Bar: typeof import("./index3").Bar;
4839
}
4940
export default Example;

testdata/baselines/reference/submodule/conformance/exportDefaultNamespace.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ someFunc.someProp = 'yo';
2020

2121
//// [exportDefaultNamespace.d.ts]
2222
declare function someFunc(): string;
23-
declare module someFunc {
23+
declare namespace someFunc {
2424
var someProp: string;
2525
}
2626
export default someFunc;

testdata/baselines/reference/submodule/conformance/exportDefaultNamespace.js.diff

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
--- old.exportDefaultNamespace.js
22
+++ new.exportDefaultNamespace.js
3-
@@= skipped -19, +19 lines =@@
4-
5-
//// [exportDefaultNamespace.d.ts]
6-
declare function someFunc(): string;
7-
-declare namespace someFunc {
8-
+declare module someFunc {
3+
@@= skipped -23, +23 lines =@@
94
var someProp: string;
105
}
116
export default someFunc;

0 commit comments

Comments
 (0)