Merge pull request #7251 from Microsoft/exportEquals

emit temp declarations after export equals
This commit is contained in:
Vladimir Matveev 2016-02-25 23:54:26 -08:00
commit 647280bc74
13 changed files with 68 additions and 3 deletions

View File

@ -7402,8 +7402,8 @@ const _super = (function (geti, seti) {
emitExportStarHelper();
emitCaptureThisForNodeIfNecessary(node);
emitLinesStartingAt(node.statements, startIndex);
emitTempDeclarations(/*newLine*/ true);
emitExportEquals(/*emitAsReturn*/ true);
emitTempDeclarations(/*newLine*/ true);
decreaseIndent();
writeLine();
write("});");
@ -7416,8 +7416,8 @@ const _super = (function (geti, seti) {
emitExportStarHelper();
emitCaptureThisForNodeIfNecessary(node);
emitLinesStartingAt(node.statements, startIndex);
emitTempDeclarations(/*newLine*/ true);
emitExportEquals(/*emitAsReturn*/ false);
emitTempDeclarations(/*newLine*/ true);
}
function emitUMDModule(node: SourceFile) {
@ -7443,8 +7443,8 @@ const _super = (function (geti, seti) {
emitExportStarHelper();
emitCaptureThisForNodeIfNecessary(node);
emitLinesStartingAt(node.statements, startIndex);
emitTempDeclarations(/*newLine*/ true);
emitExportEquals(/*emitAsReturn*/ true);
emitTempDeclarations(/*newLine*/ true);
decreaseIndent();
writeLine();
write("});");

View File

@ -0,0 +1,9 @@
//// [exportEqualsAmd.ts]
export = { ["hi"]: "there" };
//// [exportEqualsAmd.js]
define(["require", "exports"], function (require, exports) {
"use strict";
return (_a = {}, _a["hi"] = "there", _a);
var _a;
});

View File

@ -0,0 +1,3 @@
=== tests/cases/compiler/exportEqualsAmd.ts ===
export = { ["hi"]: "there" };
No type information for this code.

View File

@ -0,0 +1,6 @@
=== tests/cases/compiler/exportEqualsAmd.ts ===
export = { ["hi"]: "there" };
>{ ["hi"]: "there" } : { ["hi"]: string; }
>"hi" : string
>"there" : string

View File

@ -0,0 +1,7 @@
//// [exportEqualsCommonJs.ts]
export = { ["hi"]: "there" };
//// [exportEqualsCommonJs.js]
"use strict";
module.exports = (_a = {}, _a["hi"] = "there", _a);
var _a;

View File

@ -0,0 +1,3 @@
=== tests/cases/compiler/exportEqualsCommonJs.ts ===
export = { ["hi"]: "there" };
No type information for this code.

View File

@ -0,0 +1,6 @@
=== tests/cases/compiler/exportEqualsCommonJs.ts ===
export = { ["hi"]: "there" };
>{ ["hi"]: "there" } : { ["hi"]: string; }
>"hi" : string
>"there" : string

View File

@ -0,0 +1,16 @@
//// [exportEqualsUmd.ts]
export = { ["hi"]: "there" };
//// [exportEqualsUmd.js]
(function (factory) {
if (typeof module === 'object' && typeof module.exports === 'object') {
var v = factory(require, exports); if (v !== undefined) module.exports = v;
}
else if (typeof define === 'function' && define.amd) {
define(["require", "exports"], factory);
}
})(function (require, exports) {
"use strict";
return (_a = {}, _a["hi"] = "there", _a);
var _a;
});

View File

@ -0,0 +1,3 @@
=== tests/cases/compiler/exportEqualsUmd.ts ===
export = { ["hi"]: "there" };
No type information for this code.

View File

@ -0,0 +1,6 @@
=== tests/cases/compiler/exportEqualsUmd.ts ===
export = { ["hi"]: "there" };
>{ ["hi"]: "there" } : { ["hi"]: string; }
>"hi" : string
>"there" : string

View File

@ -0,0 +1,2 @@
// @module: amd
export = { ["hi"]: "there" };

View File

@ -0,0 +1,2 @@
// @module: commonjs
export = { ["hi"]: "there" };

View File

@ -0,0 +1,2 @@
// @module: umd
export = { ["hi"]: "there" };