Skip to content

Commit

Permalink
fix scoping in export* helper
Browse files Browse the repository at this point in the history
  • Loading branch information
mlrawlings committed Sep 25, 2019
1 parent a8d6c2b commit 27941d0
Show file tree
Hide file tree
Showing 19 changed files with 198 additions and 132 deletions.
15 changes: 9 additions & 6 deletions src/compiler/transformers/module/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1807,12 +1807,15 @@ namespace ts {
scoped: true,
text: `
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, {
enumerable: true,
get: function () {
return m[p];
}
});
for (var p in m) b(p);
function b(p) {
if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, {
enumerable: true,
get: function () {
return m[p];
}
});
}
}`
};

Expand Down
15 changes: 9 additions & 6 deletions tests/baselines/reference/ambientShorthand_reExport.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ Object.defineProperty(exports, "x", { enumerable: true, get: () => jquery_1.x })
//// [reExportAll.js]
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, {
enumerable: true,
get: function () {
return m[p];
}
});
for (var p in m) b(p);
function b(p) {
if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, {
enumerable: true,
get: function () {
return m[p];
}
});
}
}
exports.__esModule = true;
__export(require("jquery"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,15 @@ exports.ADMIN = pkg2_1.MetadataAccessor.create('1');
//// [index.js]
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, {
enumerable: true,
get: function () {
return m[p];
}
});
for (var p in m) b(p);
function b(p) {
if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, {
enumerable: true,
get: function () {
return m[p];
}
});
}
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./keys"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,15 @@ exports.ADMIN = pkg2_1.MetadataAccessor.create('1');
//// [index.js]
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, {
enumerable: true,
get: function () {
return m[p];
}
});
for (var p in m) b(p);
function b(p) {
if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, {
enumerable: true,
get: function () {
return m[p];
}
});
}
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./keys"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,15 @@ exports.ADMIN = pkg2_1.MetadataAccessor.create('1');
//// [index.js]
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, {
enumerable: true,
get: function () {
return m[p];
}
});
for (var p in m) b(p);
function b(p) {
if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, {
enumerable: true,
get: function () {
return m[p];
}
});
}
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./keys"));
Expand Down
15 changes: 9 additions & 6 deletions tests/baselines/reference/doubleUnderscoreExportStarConflict.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ exports.__foo = __foo;
//// [index.js]
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, {
enumerable: true,
get: function () {
return m[p];
}
});
for (var p in m) b(p);
function b(p) {
if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, {
enumerable: true,
get: function () {
return m[p];
}
});
}
}
exports.__esModule = true;
__export(require("./b"));
Expand Down
15 changes: 9 additions & 6 deletions tests/baselines/reference/es6ExportAllInEs5.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,15 @@ exports.x = 10;
//// [client.js]
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, {
enumerable: true,
get: function () {
return m[p];
}
});
for (var p in m) b(p);
function b(p) {
if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, {
enumerable: true,
get: function () {
return m[p];
}
});
}
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./server"));
Expand Down
15 changes: 9 additions & 6 deletions tests/baselines/reference/es6ExportEqualsInterop.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,15 @@ export * from "class-module";
"use strict";
/// <reference path="modules.d.ts"/>
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, {
enumerable: true,
get: function () {
return m[p];
}
});
for (var p in m) b(p);
function b(p) {
if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, {
enumerable: true,
get: function () {
return m[p];
}
});
}
}
exports.__esModule = true;
var z2 = require("variable");
Expand Down
15 changes: 9 additions & 6 deletions tests/baselines/reference/exportStar-amd.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,15 @@ define(["require", "exports"], function (require, exports) {
define(["require", "exports", "./t1", "./t2", "./t3"], function (require, exports, t1_1, t2_1, t3_1) {
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, {
enumerable: true,
get: function () {
return m[p];
}
});
for (var p in m) b(p);
function b(p) {
if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, {
enumerable: true,
get: function () {
return m[p];
}
});
}
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(t1_1);
Expand Down
15 changes: 9 additions & 6 deletions tests/baselines/reference/exportStar.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,15 @@ exports.z = z;
//// [t4.js]
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, {
enumerable: true,
get: function () {
return m[p];
}
});
for (var p in m) b(p);
function b(p) {
if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, {
enumerable: true,
get: function () {
return m[p];
}
});
}
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./t1"));
Expand Down
15 changes: 9 additions & 6 deletions tests/baselines/reference/exportStarForValues7.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@ define(["require", "exports"], function (require, exports) {
define(["require", "exports", "file2"], function (require, exports, file2_1) {
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, {
enumerable: true,
get: function () {
return m[p];
}
});
for (var p in m) b(p);
function b(p) {
if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, {
enumerable: true,
get: function () {
return m[p];
}
});
}
}
exports.__esModule = true;
__export(file2_1);
Expand Down
30 changes: 18 additions & 12 deletions tests/baselines/reference/exportStarForValues8.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,15 @@ define(["require", "exports"], function (require, exports) {
define(["require", "exports", "file2", "file3"], function (require, exports, file2_1, file3_1) {
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, {
enumerable: true,
get: function () {
return m[p];
}
});
for (var p in m) b(p);
function b(p) {
if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, {
enumerable: true,
get: function () {
return m[p];
}
});
}
}
exports.__esModule = true;
__export(file2_1);
Expand All @@ -60,12 +63,15 @@ define(["require", "exports", "file2", "file3"], function (require, exports, fil
define(["require", "exports", "file4"], function (require, exports, file4_1) {
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, {
enumerable: true,
get: function () {
return m[p];
}
});
for (var p in m) b(p);
function b(p) {
if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, {
enumerable: true,
get: function () {
return m[p];
}
});
}
}
exports.__esModule = true;
__export(file4_1);
Expand Down
30 changes: 18 additions & 12 deletions tests/baselines/reference/exportStarForValues9.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ define(["require", "exports"], function (require, exports) {
define(["require", "exports", "file2"], function (require, exports, file2_1) {
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, {
enumerable: true,
get: function () {
return m[p];
}
});
for (var p in m) b(p);
function b(p) {
if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, {
enumerable: true,
get: function () {
return m[p];
}
});
}
}
exports.__esModule = true;
__export(file2_1);
Expand All @@ -39,12 +42,15 @@ define(["require", "exports", "file2"], function (require, exports, file2_1) {
define(["require", "exports", "file3"], function (require, exports, file3_1) {
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, {
enumerable: true,
get: function () {
return m[p];
}
});
for (var p in m) b(p);
function b(p) {
if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, {
enumerable: true,
get: function () {
return m[p];
}
});
}
}
exports.__esModule = true;
__export(file3_1);
Expand Down
15 changes: 9 additions & 6 deletions tests/baselines/reference/exportStarFromEmptyModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,15 @@ exports.A = A;
//// [exportStarFromEmptyModule_module3.js]
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, {
enumerable: true,
get: function () {
return m[p];
}
});
for (var p in m) b(p);
function b(p) {
if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, {
enumerable: true,
get: function () {
return m[p];
}
});
}
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./exportStarFromEmptyModule_module2"));
Expand Down
15 changes: 9 additions & 6 deletions tests/baselines/reference/inlineJsxFactoryDeclarations.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,15 @@ exports.prerendered3 = renderer_1["default"].createElement("h", null);
//// [index.js]
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, {
enumerable: true,
get: function () {
return m[p];
}
});
for (var p in m) b(p);
function b(p) {
if (!exports.hasOwnProperty(p)) Object.defineProperty(exports, p, {
enumerable: true,
get: function () {
return m[p];
}
});
}
}
exports.__esModule = true;
/** @jsx dom */
Expand Down
Loading

0 comments on commit 27941d0

Please sign in to comment.