8000 emit export specifiers in system modules only if export has a value side · johnangularjs/TypeScript@c72469a · GitHub
[go: up one dir, main page]

Skip to content

Commit c72469a

Browse files
committed
emit export specifiers in system modules only if export has a value side
1 parent a5c7201 commit c72469a

File tree

5 files changed

+318
-1
lines changed

5 files changed

+318
-1
lines changed

src/compiler/emitter.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3142,6 +3142,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
31423142

31433143
function emitExportSpecifierInSystemModule(specifier: ExportSpecifier): void {
31443144
Debug.assert(compilerOptions.module === ModuleKind.System);
3145+
3146+
if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier) ) {
3147+
return;
3148+
}
31453149

31463150
writeLine();
31473151
emitStart(specifier.name);
@@ -6089,7 +6093,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
60896093
return;
60906094
}
60916095

6092-
if (isInternalModuleImportEqualsDeclaration(node)) {
6096+
if (isInternalModuleImportEqualsDeclaration(node) && resolver.isValueAliasDeclaration(node)) {
60936097
if (!hoistedVars) {
60946098
hoistedVars = [];
60956099
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
//// [tests/cases/compiler/systemModule17.ts] ////
2+
3+
//// [f1.ts]
4+
5+
6+
export class A {}
7+
export interface I {}
8+
9+
//// [f2.ts]
10+
11+
var x = 1;
12+
interface I { }
13+
14+
namespace N {
15+
export var x = 1;
16+
export interface I { }
17+
}
18+
19+
import IX = N.x;
20+
import II = N.I;
21+
import { A, A as EA, I as EI } from "f1";
22+
23+
export {x};
24+
export {x as x1};
25+
26+
export {I};
27+
export {I as I1};
28+
29+
export {A};
30+
export {A as A1};
31+
32+
export {EA};
33+
export {EA as EA1};
34+
35+
export {EI };
36+
export {EI as EI1};
37+
38+
export {IX};
39+
export {IX as IX1};
40+
41+
export {II};
42+
export {II as II1};
43+
44+
//// [f1.js]
45+
System.register([], function(exports_1) {
46+
var A;
47+
return {
48+
setters:[],
49+
execute: function() {
50+
A = (function () {
51+
function A() {
52+
}
53+
return A;
54+
})();
55+
exports_1("A", A);
56+
}
57+
}
58+
});
59+
//// [f2.js]
60+
System.register(["f1"], function(exports_1) {
61+
var f1_1;
62+
var x, N, IX;
63+
return {
64+
setters:[
65+
function (f1_1_1) {
66+
f1_1 = f1_1_1;
67+
}],
68+
execute: function() {
69+
x = 1;
70+
(function (N) {
71+
N.x = 1;
72+
})(N || (N = {}));
73+
IX = N.x;
74+
exports_1("x", x);
75+
exports_1("x1", x);
76+
exports_1("A", f1_1.A);
77+
exports_1("A1", f1_1.A);
78+
exports_1("EA", f1_1.A);
79+
exports_1("EA1", f1_1.A);
80+
exports_1("IX", IX);
81+
exports_1("IX1", IX);
82+
}
83+
}
84+
});
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
=== tests/cases/compiler/f1.ts ===
2+
3+
4+
export class A {}
5+
>A : Symbol(A, Decl(f1.ts, 0, 0))
6+
7+
export interface I {}
8+
>I : Symbol(I, Decl(f1.ts, 2, 17))
9+
10+
=== tests/cases/compiler/f2.ts ===
11+
12+
var x = 1;
13+
>x : Symbol(x, Decl(f2.ts, 1, 3))
14+
15+
interface I { }
16+
>I : Symbol(I, Decl(f2.ts, 1, 10))
17+
18+
namespace N {
19+
>N : Symbol(N, Decl(f2.ts, 2, 15))
20+
21+
export var x = 1;
22+
>x : Symbol(x, Decl(f2.ts, 5, 11))
23+
24+
export interface I { }
25+
>I : Symbol(I, Decl(f2.ts, 5, 18))
26+
}
27+
28+
import IX = N.x;
29+
>IX : Symbol(IX, Decl(f2.ts, 7, 1))
30+
>N : Symbol(N, Decl(f2.ts, 2, 15))
31+
>x : Symbol(IX, Decl(f2.ts, 5, 11))
32+
33+
import II = N.I;
34+
>II : Symbol(II, Decl(f2.ts, 9, 16))
35+
>N : Symbol(N, Decl(f2.ts, 2, 15))
36+
>I : Symbol(II, Decl(f2.ts, 5, 18))
37+
38+
import { A, A as EA, I as EI } from "f1";
39+
>A : Symbol(A, Decl(f2.ts, 11, 8))
40+
>A : Symbol(EA, Decl(f2.ts, 11, 11))
41+
>EA : Symbol(EA, Decl(f2.ts, 11, 11))
42+
>I : Symbol(EI, Decl(f2.ts, 11, 20))
43+
>EI : Symbol(EI, Decl(f2.ts, 11, 20))
44+
45+
export {x};
46+
>x : Symbol(x, Decl(f2.ts, 13, 8))
47+
48+
export {x as x1};
49+
>x : Symbol(x1, Decl(f2.ts, 14, 8))
50+
>x1 : Symbol(x1, Decl(f2.ts, 14, 8))
51+
52+
export {I};
53+
>I : Symbol(I, Decl(f2.ts, 16, 8))
54+
55+
export {I as I1};
56+
>I : Symbol(I1, Decl(f2.ts, 17, 8))
57+
>I1 : Symbol(I1, Decl(f2.ts, 17, 8))
58+
59+
export {A};
60+
>A : Symbol(A, Decl(f2.ts, 19, 8))
61+
62+
export {A as A1};
63+
>A : Symbol(A1, Decl(f2.ts, 20, 8))
64+
>A1 : Symbol(A1, Decl(f2.ts, 20, 8))
65+
66+
export {EA};
67+
>EA : Symbol(EA, Decl(f2.ts, 22, 8))
68+
69+
export {EA as EA1};
70+
>EA : Symbol(EA1, Decl(f2.ts, 23, 8))
71+
>EA1 : Symbol(EA1, Decl(f2.ts, 23, 8))
72+
73+
export {EI };
74+
>EI : Symbol(EI, Decl(f2.ts, 25, 8))
75+
76+
export {EI as EI1};
77+
>EI : Symbol(EI1, Decl(f2.ts, 26, 8))
78+
>EI1 : Symbol(EI1, Decl(f2.ts, 26, 8))
79+
80+
export {IX};
81+
>IX : Symbol(IX, Decl(f2.ts, 28, 8))
82+
83+
export {IX as IX1};
84+
>IX : Symbol(IX1, Decl(f2.ts, 29, 8))
85+
>IX1 : Symbol(IX1, Decl(f2.ts, 29, 8))
86+
87+
export {II};
88+
>II : Symbol(II, Decl(f2.ts, 31, 8))
89+
90+
export {II as II1};
91+
>II : Symbol(II1, Decl(f2.ts, 32, 8))
92+
>II1 : Symbol(II1, Decl(f2.ts, 32, 8))
93+
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
=== tests/cases/compiler/f1.ts ===
2+
3+
4+
export class A {}
5+
>A : A
6+
7+
export interface I {}
8+
>I : I
9+
10+
=== tests/cases/compiler/f2.ts ===
11+
12+
var x = 1;
13+
>x : number
14+
>1 : number
15+
16+
interface I { }
17+
>I : I
18+
19+
namespace N {
20+
>N : typeof N
21+
22+
export var x = 1;
23+
>x : number
24+
>1 : number
25+
26+
export interface I { }
27+
>I : I
28+
}
29+
30+
import IX = N.x;
31+
>IX : number
32+
>N : typeof N
33+
>x : number
34+
35+
import II = N.I;
36+
>II : any
37+
>N : typeof N
38+
>I : II
39+
40+
import { A, A as EA, I as EI } from "f1";
41+
>A : typeof A
42+
>A : typeof A
43+
>EA : typeof A
44+
>I : any
45+
>EI : any
46+
47+
export {x};
48+
>x : number
49+
50+
export {x as x1};
51+
>x : number
52+
>x1 : number
53+
54+
export {I};
55+
>I : any
56+
57+
export {I as I1};
58+
>I : any
59+
>I1 : any
60+
61+
export {A};
62+
>A : typeof A
63+
64+
export {A as A1};
65+
>A : typeof A
66+
>A1 : typeof A
67+
68+
export {EA};
69+
>EA : typeof A
70+
71+
export {EA as EA1};
72+
>EA : typeof A
73+
>EA1 : typeof A
74+
75+
export {EI };
76+
>EI : any
77+
78+
export {EI as EI1};
79+
>EI : any
80+
>EI1 : any
81+
82+
export {IX};
83+
>IX : number
84+
85+
export {IX as IX1};
86+
>IX : number
87+
>IX1 : number
88+
89+
export {II};
90+
>II : any
91+
92+
export {II as II1};
93+
>II : any
94+
>II1 : any
95+
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// @module: system
2+
3+
// @filename: f1.ts
4+
5+
export class A {}
6+
export interface I {}
7+
8+
// @filename: f2.ts
9+
10+
var x = 1;
11+
interface I { }
12+
13+
namespace N {
14+
export var x = 1;
15+
export interface I { }
16+
}
17+
18+
import IX = N.x;
19+
import II = N.I;
20+
import { A, A as EA, I as EI } from "f1";
21+
22+
export {x};
23+
export {x as x1};
24+
25+
export {I};
26+
export {I as I1};
27+
28+
export {A};
29+
export {A as A1};
30+
31+
export {EA};
32+
export {EA as EA1};
33+
34+
export {EI };
35+
export {EI as EI1};
36+
37+
export {IX};
38+
export {IX as IX1};
39+
40+
export {II};
41+
export {II as II1};

0 commit comments

Comments
 (0)
0