fix(es/typescript): Allow empty nested namespaces (#3754)

Co-authored-by: Donny/강동윤 <kdy1997.dev@gmail.com>
This commit is contained in:
magic-akari 2022-02-27 14:52:17 +08:00 committed by GitHub
parent d5a520b092
commit f5a3647364
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 61 additions and 29 deletions

View File

@ -18,8 +18,9 @@ export var E;
(function(E) {
var z = E.z = 1;
})(E || (E = {}));
(function(N) {
var x = N.x = 1;
export var N;
(function(N1) {
var x = N1.x = 1;
})(N || (N = {}));
export function F() {}
(function(F1) {

View File

@ -1,4 +1,4 @@
var E;
var E, N;
export class C {
}
(C || (C = {})).x = 1, (function(E) {

View File

@ -25,8 +25,9 @@ export var E;
(function(E) {
var z = E.z = 1;
})(E || (E = {}));
(function(N) {
var x = N.x = 1;
export var N;
(function(N1) {
var x = N1.x = 1;
})(N || (N = {}));
export function F() {}
(function(F1) {

View File

@ -1,15 +1,15 @@
var C, E, E1, N1, F, E2, C1 = function() {
var C, E, E1, N, F, E2, N1, C1 = function() {
"use strict";
!function(instance, Constructor) {
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
}(this, C1);
};
export { E1 as E, N1 as N, E2 as E, C1 as C };
export { E1 as E, E2 as E, N1 as N, C1 as C };
C = C1 || (C1 = {}), C.x = 1, (function(E2) {
E2[E2.w = 1] = "w";
})(E2 || (E2 = {})), (function(E2) {
E2[E2.x = 2] = "x";
})(E2 || (E2 = {})), E = E2 || (E2 = {}), E.y = 1, E1 = E2 || (E2 = {}), E1.z = 1, N1 = N || (N = {}), N1.x = 1;
})(E2 || (E2 = {})), E = E2 || (E2 = {}), E.y = 1, E1 = E2 || (E2 = {}), E1.z = 1, N = N1 || (N1 = {}), N.x = 1;
function F1() {}
export { F1 as F };
F = F1 || (F1 = {}), F.x = 1;

View File

@ -18,8 +18,9 @@ export var E;
(function(E) {
var z = E.z = 1;
})(E || (E = {}));
(function(N) {
var x = N.x = 1;
export var N;
(function(N1) {
var x = N1.x = 1;
})(N || (N = {}));
export function F() {}
(function(F1) {

View File

@ -1,4 +1,4 @@
var E;
var E, N;
export class C {
}
(C || (C = {})).x = 1, (function(E) {

View File

@ -25,8 +25,9 @@ export var E;
(function(E) {
var z = E.z = 1;
})(E || (E = {}));
(function(N) {
var x = N.x = 1;
export var N;
(function(N1) {
var x = N1.x = 1;
})(N || (N = {}));
export function F() {}
(function(F1) {

View File

@ -1,15 +1,15 @@
var C, E, E1, N1, F, E2, C1 = function() {
var C, E, E1, N, F, E2, N1, C1 = function() {
"use strict";
!function(instance, Constructor) {
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
}(this, C1);
};
export { E1 as E, N1 as N, E2 as E, C1 as C };
export { E1 as E, E2 as E, N1 as N, C1 as C };
C = C1 || (C1 = {}), C.x = 1, (function(E2) {
E2[E2.w = 1] = "w";
})(E2 || (E2 = {})), (function(E2) {
E2[E2.x = 2] = "x";
})(E2 || (E2 = {})), E = E2 || (E2 = {}), E.y = 1, E1 = E2 || (E2 = {}), E1.z = 1, N1 = N || (N = {}), N1.x = 1;
})(E2 || (E2 = {})), E = E2 || (E2 = {}), E.y = 1, E1 = E2 || (E2 = {}), E1.z = 1, N = N1 || (N1 = {}), N.x = 1;
function F1() {}
export { F1 as F };
F = F1 || (F1 = {}), F.x = 1;

View File

@ -1,18 +1,20 @@
(function(A) {
var A;
(function(A1) {
let B;
(function(B) {
var Point = {
x: 0,
y: 0
}; // bug 832088: could not find module 'C'
})(B = A.B || (A.B = {}));
})(B = A1.B || (A1.B = {}));
})(A || (A = {}));
(function(M2) {
var M2;
(function(M21) {
let X1;
(function(X) {
var Point;
X.Point = Point;
})(X1 = M2.X || (M2.X = {}));
})(X1 = M21.X || (M21.X = {}));
})(M2 || (M2 = {}));
var m = M2.X;
var point;

View File

@ -1,4 +1,5 @@
!function(M2) {
var M2;
!function(M21) {
var Point;
(M2.X || (M2.X = {})).Point = Point;
(M21.X || (M21.X = {})).Point = Point;
}(M2 || (M2 = {})), M2.X.Point;

View File

@ -1,18 +1,20 @@
(function(A) {
var A;
(function(A1) {
var B;
(function(B) {
var Point = {
x: 0,
y: 0
}; // bug 832088: could not find module 'C'
})(B = A.B || (A.B = {}));
})(B = A1.B || (A1.B = {}));
})(A || (A = {}));
(function(M2) {
var M2;
(function(M21) {
var X1;
(function(X) {
var Point;
X.Point = Point;
})(X1 = M2.X || (M2.X = {}));
})(X1 = M21.X || (M21.X = {}));
})(M2 || (M2 = {}));
var m = M2.X;
var point;

View File

@ -1,4 +1,5 @@
!function(M2) {
var M2;
!function(M21) {
var Point;
(M2.X || (M2.X = {})).Point = Point;
(M21.X || (M21.X = {})).Point = Point;
}(M2 || (M2 = {})), M2.X.Point;

View File

@ -1144,7 +1144,6 @@ where
};
let body = module.body?;
let var = self.create_uninit_var(module_name.span, module_name.to_id());
let private_name = private_ident!(module_name.sym.clone());
let body_stmts = match body {
TsNamespaceBody::TsModuleBlock(block) => {
@ -1155,6 +1154,8 @@ where
}
}?;
let var = self.create_uninit_var(module_name.span, module_name.to_id());
self.get_namespace_var_decl_and_call_expr(
var,
body_stmts,

View File

@ -0,0 +1,11 @@
export namespace a.b {
export interface i {
baz?: string;
}
}
export namespace a.b {
export enum e {
FOO = "BAR",
}
}

View File

@ -0,0 +1,10 @@
export var a;
(function(a1) {
let b1;
(function(b) {
let e;
(function(e) {
e["FOO"] = "BAR";
})(e = b.e || (b.e = {}));
})(b1 = a1.b || (a1.b = {}));
})(a || (a = {}));