Skip to content

Commit 586abac

Browse files
committed
Merge pull request #4179 from Microsoft/exportDeclarationsInSystem
emit export declarations for system modules as a part of 'execute' me…
2 parents bfa624c + 7ecaea3 commit 586abac

18 files changed

+605
-176
lines changed

src/compiler/emitter.ts

Lines changed: 130 additions & 119 deletions
Large diffs are not rendered by default.

tests/baselines/reference/aliasesInSystemModule1.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ System.register(['foo'], function(exports_1) {
2222
var cls, cls2, x, y, z, M;
2323
return {
2424
setters:[
25-
function (_alias) {
26-
alias = _alias;
25+
function (alias_1) {
26+
alias = alias_1;
2727
}],
2828
execute: function() {
2929
cls = alias.Class;

tests/baselines/reference/aliasesInSystemModule2.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ System.register(["foo"], function(exports_1) {
2121
var cls, cls2, x, y, z, M;
2222
return {
2323
setters:[
24-
function (_foo_1) {
25-
foo_1 = _foo_1;
24+
function (foo_1_1) {
25+
foo_1 = foo_1_1;
2626
}],
2727
execute: function() {
2828
cls = foo_1.alias.Class;

tests/baselines/reference/systemModule10.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ System.register(['file1', 'file2'], function(exports_1) {
1414
var file1_1, n2;
1515
return {
1616
setters:[
17-
function (_file1_1) {
18-
file1_1 = _file1_1;
19-
exports_1("n", file1_1["default"]);
20-
exports_1("n1", file1_1["default"]);
21-
exports_1("x", file1_1.x);
22-
exports_1("y", file1_1.x);
17+
function (file1_1_1) {
18+
file1_1 = file1_1_1;
2319
},
24-
function (_n2) {
25-
n2 = _n2;
26-
exports_1("n2", n2);
27-
exports_1("n3", n2);
20+
function (n2_1) {
21+
n2 = n2_1;
2822
}],
2923
execute: function() {
24+
exports_1("x", file1_1.x);
25+
exports_1("y", file1_1.x);
26+
exports_1("n", file1_1["default"]);
27+
exports_1("n1", file1_1["default"]);
28+
exports_1("n2", n2);
29+
exports_1("n3", n2);
3030
}
3131
}
3232
});

tests/baselines/reference/systemModule10_ES5.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ System.register(['file1', 'file2'], function(exports_1) {
1414
var file1_1, n2;
1515
return {
1616
setters:[
17-
function (_file1_1) {
18-
file1_1 = _file1_1;
19-
exports_1("n", file1_1.default);
20-
exports_1("n1", file1_1.default);
21-
exports_1("x", file1_1.x);
22-
exports_1("y", file1_1.x);
17+
function (file1_1_1) {
18+
file1_1 = file1_1_1;
2319
},
24-
function (_n2) {
25-
n2 = _n2;
26-
exports_1("n2", n2);
27-
exports_1("n3", n2);
20+
function (n2_1) {
21+
n2 = n2_1;
2822
}],
2923
execute: function() {
24+
exports_1("x", file1_1.x);
25+
exports_1("y", file1_1.x);
26+
exports_1("n", file1_1.default);
27+
exports_1("n1", file1_1.default);
28+
exports_1("n2", n2);
29+
exports_1("n3", n2);
3030
}
3131
}
3232
});

tests/baselines/reference/systemModule11.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ System.register(['bar'], function(exports_1) {
5959
}
6060
return {
6161
setters:[
62-
function (_bar_1) {
63-
exportStar_1(_bar_1);
62+
function (bar_1_1) {
63+
exportStar_1(bar_1_1);
6464
}],
6565
execute: function() {
6666
}
@@ -82,8 +82,8 @@ System.register(['bar'], function(exports_1) {
8282
}
8383
return {
8484
setters:[
85-
function (_bar_1) {
86-
exportStar_1(_bar_1);
85+
function (bar_1_1) {
86+
exportStar_1(bar_1_1);
8787
}],
8888
execute: function() {
8989
exports_1("x", x);
@@ -108,14 +108,14 @@ System.register(['a', 'bar'], function(exports_1) {
108108
}
109109
return {
110110
setters:[
111-
function (_a_1) {
112-
var reexports_1 = {};
113-
reexports_1["x"] = _a_1["x"];
114-
reexports_1["z"] = _a_1["y"];
115-
exports_1(reexports_1);
111+
function (a_1_1) {
112+
exports_1({
113+
"x": a_1_1["x"],
114+
"z": a_1_1["y"]
115+
});
116116
},
117-
function (_bar_1) {
118-
exportStar_1(_bar_1);
117+
function (bar_1_1) {
118+
exportStar_1(bar_1_1);
119119
}],
120120
execute: function() {
121121
}
@@ -130,11 +130,11 @@ System.register(['a'], function(exports_1) {
130130
exports_1("default", default_1);
131131
return {
132132
setters:[
133-
function (_a_1) {
134-
var reexports_1 = {};
135-
reexports_1["s"] = _a_1["s"];
136-
reexports_1["s2"] = _a_1["s1"];
137-
exports_1(reexports_1);
133+
function (a_1_1) {
134+
exports_1({
135+
"s": a_1_1["s"],
136+
"s2": a_1_1["s1"]
137+
});
138138
}],
139139
execute: function() {
140140
exports_1("z", z);
@@ -154,8 +154,8 @@ System.register(['a'], function(exports_1) {
154154
}
155155
return {
156156
setters:[
157-
function (_a_1) {
158-
exportStar_1(_a_1);
157+
function (a_1_1) {
158+
exportStar_1(a_1_1);
159159
}],
160160
execute: function() {
161161
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
tests/cases/compiler/systemModule14.ts(6,17): error TS2307: Cannot find module 'foo'.
2+
3+
4+
==== tests/cases/compiler/systemModule14.ts (1 errors) ====
5+
6+
function foo() {
7+
return a;
8+
}
9+
10+
import {a} from "foo";
11+
~~~~~
12+
!!! error TS2307: Cannot find module 'foo'.
13+
export {foo}
14+
15+
var x = 1;
16+
export {foo as b}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//// [systemModule14.ts]
2+
3+
function foo() {
4+
return a;
5+
}
6+
7+
import {a} from "foo";
8+
export {foo}
9+
10+
var x = 1;
11+
export {foo as b}
12+
13+
//// [systemModule14.js]
14+
System.register(["foo"], function(exports_1) {
15+
var foo_1;
16+
var x;
17+
function foo() {
18+
return foo_1.a;
19+
}
20+
return {
21+
setters:[
22+
function (foo_1_1) {
23+
foo_1 = foo_1_1;
24+
}],
25+
execute: function() {
26+
exports_1("foo", foo);
27+
x = 1;
28+
exports_1("b", foo);
29+
}
30+
}
31+
});
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
//// [tests/cases/compiler/systemModule15.ts] ////
2+
3+
//// [file1.ts]
4+
5+
6+
import * as moduleB from "./file2"
7+
8+
declare function use(v: any): void;
9+
10+
use(moduleB.value);
11+
use(moduleB.moduleC);
12+
use(moduleB.moduleCStar);
13+
14+
//// [file2.ts]
15+
16+
import * as moduleCStar from "./file3"
17+
import {value2} from "./file4"
18+
import moduleC from "./file3"
19+
import {value} from "./file3"
20+
21+
export {
22+
moduleCStar,
23+
moduleC,
24+
value
25+
}
26+
27+
//// [file3.ts]
28+
29+
export var value = "youpi";
30+
export default value;
31+
32+
//// [file4.ts]
33+
34+
export var value2 = "v";
35+
36+
//// [file3.js]
37+
System.register([], function(exports_1) {
38+
var value;
39+
return {
40+
setters:[],
41+
execute: function() {
42+
exports_1("value", value = "youpi");
43+
exports_1("default",value);
44+
}
45+
}
46+
});
47+
//// [file4.js]
48+
System.register([], function(exports_1) {
49+
var value2;
50+
return {
51+
setters:[],
52+
execute: function() {
53+
exports_1("value2", value2 = "v");
54+
}
55+
}
56+
});
57+
//// [file2.js]
58+
System.register(["./file3"], function(exports_1) {
59+
var moduleCStar, file3_1, file3_2;
60+
return {
61+
setters:[
62+
function (moduleCStar_1) {
63+
moduleCStar = moduleCStar_1;
64+
file3_1 = moduleCStar_1;
65+
file3_2 = moduleCStar_1;
66+
}],
67+
execute: function() {
68+
exports_1("moduleCStar", moduleCStar);
69+
exports_1("moduleC", file3_1["default"]);
70+
exports_1("value", file3_2.value);
71+
}
72+
}
73+
});
74+
//// [file1.js]
75+
System.register(["./file2"], function(exports_1) {
76+
var moduleB;
77+
return {
78+
setters:[
79+
function (moduleB_1) {
80+
moduleB = moduleB_1;
81+
}],
82+
execute: function() {
83+
use(moduleB.value);
84+
use(moduleB.moduleC);
85+
use(moduleB.moduleCStar);
86+
}
87+
}
88+
});
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
=== tests/cases/compiler/file1.ts ===
2+
3+
4+
import * as moduleB from "./file2"
5+
>moduleB : Symbol(moduleB, Decl(file1.ts, 2, 6))
6+
7+
declare function use(v: any): void;
8+
>use : Symbol(use, Decl(file1.ts, 2, 34))
9+
>v : Symbol(v, Decl(file1.ts, 4, 21))
10+
11+
use(moduleB.value);
12+
>use : Symbol(use, Decl(file1.ts, 2, 34))
13+
>moduleB.value : Symbol(moduleB.value, Decl(file2.ts, 8, 12))
14+
>moduleB : Symbol(moduleB, Decl(file1.ts, 2, 6))
15+
>value : Symbol(moduleB.value, Decl(file2.ts, 8, 12))
16+
17+
use(moduleB.moduleC);
18+
>use : Symbol(use, Decl(file1.ts, 2, 34))
19+
>moduleB.moduleC : Symbol(moduleB.moduleC, Decl(file2.ts, 7, 16))
20+
>moduleB : Symbol(moduleB, Decl(file1.ts, 2, 6))
21+
>moduleC : Symbol(moduleB.moduleC, Decl(file2.ts, 7, 16))
22+
23+
use(moduleB.moduleCStar);
24+
>use : Symbol(use, Decl(file1.ts, 2, 34))
25+
>moduleB.moduleCStar : Symbol(moduleB.moduleCStar, Decl(file2.ts, 6, 8))
26+
>moduleB : Symbol(moduleB, Decl(file1.ts, 2, 6))
27+
>moduleCStar : Symbol(moduleB.moduleCStar, Decl(file2.ts, 6, 8))
28+
29+
=== tests/cases/compiler/file2.ts ===
30+
31+
import * as moduleCStar from "./file3"
32+
>moduleCStar : Symbol(moduleCStar, Decl(file2.ts, 1, 6))
33+
34+
import {value2} from "./file4"
35+
>value2 : Symbol(value2, Decl(file2.ts, 2, 8))
36+
37+
import moduleC from "./file3"
38+
>moduleC : Symbol(moduleC, Decl(file2.ts, 3, 6))
39+
40+
import {value} from "./file3"
41+
>value : Symbol(value, Decl(file2.ts, 4, 8))
42+
43+
export {
44+
moduleCStar,
45+
>moduleCStar : Symbol(moduleCStar, Decl(file2.ts, 6, 8))
46+
47+
moduleC,
48+
>moduleC : Symbol(moduleC, Decl(file2.ts, 7, 16))
49+
50+
value
51+
>value : Symbol(value, Decl(file2.ts, 8, 12))
52+
}
53+
54+
=== tests/cases/compiler/file3.ts ===
55+
56+
export var value = "youpi";
57+
>value : Symbol(value, Decl(file3.ts, 1, 10))
58+
59+
export default value;
60+
>value : Symbol(value, Decl(file3.ts, 1, 10))
61+
62+
=== tests/cases/compiler/file4.ts ===
63+
64+
export var value2 = "v";
65+
>value2 : Symbol(value2, Decl(file4.ts, 1, 10))
66+

0 commit comments

Comments
 (0)