8000 Merge pull request #7251 from Microsoft/exportEquals · sweshgit/TypeScript@647280b · GitHub
[go: up one dir, main page]

Skip to content

Commit 647280b

Browse files
committed
Merge pull request microsoft#7251 from Microsoft/exportEquals
emit temp declarations after export equals
2 parents 8074dbd + 66cf56e commit 647280b

13 files changed

+68
-3
lines changed

src/compiler/emitter.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7402,8 +7402,8 @@ const _super = (function (geti, seti) {
74027402
emitExportStarHelper();
74037403
emitCaptureThisForNodeIfNecessary(node);
74047404
emitLinesStartingAt(node.statements, startIndex);
7405-
emitTempDeclarations(/*newLine*/ true);
74067405
emitExportEquals(/*emitAsReturn*/ true);
7406+
emitTempDeclarations(/*newLine*/ true);
74077407
decreaseIndent();
74087408
writeLine();
74097409
write("});");
@@ -7416,8 +7416,8 @@ const _super = (function (geti, seti) {
74167416
emitExportStarHelper();
74177417
emitCaptureThisForNodeIfNecessary(node);
74187418
emitLinesStartingAt(node.statements, startIndex);
7419-
emitTempDeclarations(/*newLine*/ true);
74207419
emitExportEquals(/*emitAsReturn*/ false);
7420+
emitTempDeclarations(/*newLine*/ true);
74217421
}
74227422

74237423
function emitUMDModule(node: SourceFile) {
@@ -7443,8 +7443,8 @@ const _super = (function (geti, seti) {
74437443
emitExportStarHelper();
74447444
emitCaptureThisForNodeIfNecessary(node);
74457445
emitLinesStartingAt(node.statements, startIndex);
7446-
emitTempDeclarations(/*newLine*/ true);
74477446
emitExportEquals(/*emitAsReturn*/ true);
7447+
emitTempDeclarations(/*newLine*/ true);
74487448
decreaseIndent();
74497449
writeLine();
74507450
write("});");
Lines changed: 9 additions & 0 deletions
8000
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//// [exportEqualsAmd.ts]
2+
export = { ["hi"]: "there" };
3+
4+
//// [exportEqualsAmd.js]
5+
define(["require", "exports"], function (require, exports) {
6+
"use strict";
7+
return (_a = {}, _a["hi"] = "there", _a);
8+
var _a;
9+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
=== tests/cases/compiler/exportEqualsAmd.ts ===
2+
export = { ["hi"]: "there" };
3+
No type information for this code.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
=== tests/cases/compiler/exportEqualsAmd.ts ===
2+
export = { ["hi"]: "there" };
3+
>{ ["hi"]: "there" } : { ["hi"]: string; }
4+
>"hi" : string
5+
>"there" : string
6+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//// [exportEqualsCommonJs.ts]
2+
export = { ["hi"]: "there" };
3+
4+
//// [exportEqualsCommonJs.js]
5+
"use strict";
6+
module.exports = (_a = {}, _a["hi"] = "there", _a);
7+
var _a;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
=== tests/cases/compiler/exportEqualsCommonJs.ts ===
2+
export = { ["hi"]: "there" };
3+
No type information for this code.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
=== tests/cases/compiler/exportEqualsCommonJs.ts ===
2+
export = { ["hi"]: "there" };
3+
>{ ["hi"]: "there" } : { ["hi"]: string; }
4+
>"hi" : string
5+
>"there" : string
6+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//// [exportEqualsUmd.ts]
2+
export = { ["hi"]: "there" };
3+
4+
//// [exportEqualsUmd.js]
5+
(function (factory) {
6+
if (typeof module === 'object' && typeof module.exports === 'object') {
7+
var v = factory(require, exports); if (v !== undefined) module.exports = v;
8+
}
9+
else if (typeof define === 'function' && define.amd) {
10+
define(["require", "exports"], factory);
11+
}
12+
})(function (require, exports) {
13+
"use strict";
14+
return (_a = {}, _a["hi"] = "there", _a);
15+
var _a;
16+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
=== tests/cases/compiler/exportEqualsUmd.ts ===
2+
export = { ["hi"]: "there" };
3+
No type information for this code.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
=== tests/cases/compiler/exportEqualsUmd.ts ===
2+
export = { ["hi"]: "there" };
3+
>{ ["hi"]: "there" } : { ["hi"]: string; }
4+
>"hi" : string
5+
>"there" : string
6+

0 commit comments

Comments
 (0)
0