Skip to content

Commit

Permalink
Exempt tslib from indirect call transform (microsoft#47070)
Browse files Browse the repository at this point in the history
  • Loading branch information
rbuckton authored and mprobst committed Jan 10, 2022
1 parent 231a026 commit 67f9895
Show file tree
Hide file tree
Showing 34 changed files with 94 additions and 94 deletions.
4 changes: 2 additions & 2 deletions src/compiler/transformers/module/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1853,7 +1853,7 @@ namespace ts {
if (isIdentifier(node.expression)) {
const expression = substituteExpressionIdentifier(node.expression);
noSubstitution[getNodeId(expression)] = true;
if (!isIdentifier(expression)) {
if (!isIdentifier(expression) && !(getEmitFlags(node.expression) & EmitFlags.HelperName)) {
return addEmitFlags(
factory.updateCallExpression(node,
expression,
Expand All @@ -1872,7 +1872,7 @@ namespace ts {
if (isIdentifier(node.tag)) {
const tag = substituteExpressionIdentifier(node.tag);
noSubstitution[getNodeId(tag)] = true;
if (!isIdentifier(tag)) {
if (!isIdentifier(tag) && !(getEmitFlags(node.tag) & EmitFlags.HelperName)) {
return addEmitFlags(
factory.updateTaggedTemplateExpression(node,
tag,
Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/es5-importHelpersAsyncFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.foo = void 0;
var tslib_1 = require("tslib");
function foo() {
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
return (0, tslib_1.__generator)(this, function (_a) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
return [2 /*return*/];
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ exports.username = username;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
(0, tslib_1.__exportStar)(require("./username"), exports);
tslib_1.__exportStar(require("./username"), exports);
//// [hello.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
Expand All @@ -36,6 +36,6 @@ exports.default = sayHello;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const hello_1 = (0, tslib_1.__importDefault)(require("./hello"));
const hello_1 = tslib_1.__importDefault(require("./hello"));
const utils_1 = require("./utils");
(0, hello_1.default)((0, utils_1.username)());
8 changes: 4 additions & 4 deletions tests/baselines/reference/esModuleInteropTslibHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export { Bar }
exports.__esModule = true;
exports.Foo = void 0;
var tslib_1 = require("tslib");
var path_1 = (0, tslib_1.__importDefault)(require("path"));
var path_1 = tslib_1.__importDefault(require("path"));
path_1["default"].resolve("", "../");
var Foo = /** @class */ (function () {
function Foo() {
Expand All @@ -37,7 +37,7 @@ exports.Foo = Foo;
exports.__esModule = true;
exports.Foo2 = void 0;
var tslib_1 = require("tslib");
var path = (0, tslib_1.__importStar)(require("path"));
var path = tslib_1.__importStar(require("path"));
path.resolve("", "../");
var Foo2 = /** @class */ (function () {
function Foo2() {
Expand All @@ -50,7 +50,7 @@ exports.Foo2 = Foo2;
exports.__esModule = true;
exports.Foo3 = void 0;
var tslib_1 = require("tslib");
var path_1 = (0, tslib_1.__importDefault)(require("path"));
var path_1 = tslib_1.__importDefault(require("path"));
(0, path_1["default"])("", "../");
var Foo3 = /** @class */ (function () {
function Foo3() {
Expand All @@ -63,6 +63,6 @@ exports.Foo3 = Foo3;
exports.__esModule = true;
exports.Bar = void 0;
var tslib_1 = require("tslib");
var path_1 = (0, tslib_1.__importStar)(require("path"));
var path_1 = tslib_1.__importStar(require("path"));
exports.Bar = path_1.Bar;
(0, path_1["default"])("", "../");
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ exports.__esModule = true;
exports.__esModule = true;
exports.ns = void 0;
var tslib_1 = require("tslib");
exports.ns = (0, tslib_1.__importStar)(require("./a")); // Error
exports.ns = tslib_1.__importStar(require("./a")); // Error
16 changes: 8 additions & 8 deletions tests/baselines/reference/importHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ var A = /** @class */ (function () {
}());
exports.A = A;
var B = /** @class */ (function (_super) {
(0, tslib_1.__extends)(B, _super);
tslib_1.__extends(B, _super);
function B() {
return _super !== null && _super.apply(this, arguments) || this;
}
Expand All @@ -70,21 +70,21 @@ var C = /** @class */ (function () {
}
C.prototype.method = function (x) {
};
(0, tslib_1.__decorate)([
(0, tslib_1.__param)(0, dec),
(0, tslib_1.__metadata)("design:type", Function),
(0, tslib_1.__metadata)("design:paramtypes", [Number]),
(0, tslib_1.__metadata)("design:returntype", void 0)
tslib_1.__decorate([
tslib_1.__param(0, dec),
tslib_1.__metadata("design:type", Function),
tslib_1.__metadata("design:paramtypes", [Number]),
tslib_1.__metadata("design:returntype", void 0)
], C.prototype, "method", null);
C = (0, tslib_1.__decorate)([
C = tslib_1.__decorate([
dec
], C);
return C;
}());
function id(x) {
return x;
}
exports.result = id(templateObject_1 || (templateObject_1 = (0, tslib_1.__makeTemplateObject)(["hello world"], ["hello world"])));
exports.result = id(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["hello world"], ["hello world"])));
var templateObject_1;
//// [script.js]
var __extends = (this && this.__extends) || (function () {
Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/importHelpersAmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ define(["require", "exports", "tslib", "./a", "./a"], function (require, exports
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.B = void 0;
(0, tslib_1.__exportStar)(a_2, exports);
tslib_1.__exportStar(a_2, exports);
var B = /** @class */ (function (_super) {
(0, tslib_1.__extends)(B, _super);
tslib_1.__extends(B, _super);
function B() {
return _super !== null && _super.apply(this, arguments) || this;
}
Expand Down
28 changes: 14 additions & 14 deletions tests/baselines/reference/importHelpersInIsolatedModules.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var A = /** @class */ (function () {
}());
exports.A = A;
var B = /** @class */ (function (_super) {
(0, tslib_1.__extends)(B, _super);
tslib_1.__extends(B, _super);
function B() {
return _super !== null && _super.apply(this, arguments) || this;
}
Expand All @@ -57,13 +57,13 @@ var C = /** @class */ (function () {
}
C.prototype.method = function (x) {
};
(0, tslib_1.__decorate)([
(0, tslib_1.__param)(0, dec),
(0, tslib_1.__metadata)("design:type", Function),
(0, tslib_1.__metadata)("design:paramtypes", [Number]),
(0, tslib_1.__metadata)("design:returntype", void 0)
tslib_1.__decorate([
tslib_1.__param(0, dec),
tslib_1.__metadata("design:type", Function),
tslib_1.__metadata("design:paramtypes", [Number]),
tslib_1.__metadata("design:returntype", void 0)
], C.prototype, "method", null);
C = (0, tslib_1.__decorate)([
C = tslib_1.__decorate([
dec
], C);
return C;
Expand All @@ -76,7 +76,7 @@ var A = /** @class */ (function () {
return A;
}());
var B = /** @class */ (function (_super) {
(0, tslib_1.__extends)(B, _super);
tslib_1.__extends(B, _super);
function B() {
return _super !== null && _super.apply(this, arguments) || this;
}
Expand All @@ -87,13 +87,13 @@ var C = /** @class */ (function () {
}
C.prototype.method = function (x) {
};
(0, tslib_1.__decorate)([
(0, tslib_1.__param)(0, dec),
(0, tslib_1.__metadata)("design:type", Function),
(0, tslib_1.__metadata)("design:paramtypes", [Number]),
(0, tslib_1.__metadata)("design:returntype", void 0)
tslib_1.__decorate([
tslib_1.__param(0, dec),
tslib_1.__metadata("design:type", Function),
tslib_1.__metadata("design:paramtypes", [Number]),
tslib_1.__metadata("design:returntype", void 0)
], C.prototype, "method", null);
C = (0, tslib_1.__decorate)([
C = tslib_1.__decorate([
dec
], C);
return C;
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/importHelpersInTsx.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export declare function __awaiter(thisArg: any, _arguments: any, P: Function, ge
Object.defineProperty(exports, "__esModule", { value: true });
exports.x = void 0;
var tslib_1 = require("tslib");
exports.x = React.createElement("span", (0, tslib_1.__assign)({}, o));
exports.x = React.createElement("span", tslib_1.__assign({}, o));
//// [script.js]
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
Expand Down
20 changes: 10 additions & 10 deletions tests/baselines/reference/importHelpersNoHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ exports.x = 1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.B = exports.A = void 0;
var tslib_1 = require("tslib");
(0, tslib_1.__exportStar)(require("./other"), exports);
tslib_1.__exportStar(require("./other"), exports);
var A = /** @class */ (function () {
function A() {
}
return A;
}());
exports.A = A;
var B = /** @class */ (function (_super) {
(0, tslib_1.__extends)(B, _super);
tslib_1.__extends(B, _super);
function B() {
return _super !== null && _super.apply(this, arguments) || this;
}
Expand All @@ -66,20 +66,20 @@ var C = /** @class */ (function () {
}
C.prototype.method = function (x) {
};
(0, tslib_1.__decorate)([
(0, tslib_1.__param)(0, dec),
(0, tslib_1.__metadata)("design:type", Function),
(0, tslib_1.__metadata)("design:paramtypes", [Number]),
(0, tslib_1.__metadata)("design:returntype", void 0)
tslib_1.__decorate([
tslib_1.__param(0, dec),
tslib_1.__metadata("design:type", Function),
tslib_1.__metadata("design:paramtypes", [Number]),
tslib_1.__metadata("design:returntype", void 0)
], C.prototype, "method", null);
C = (0, tslib_1.__decorate)([
C = tslib_1.__decorate([
dec
], C);
return C;
}());
var o = { a: 1 };
var y = (0, tslib_1.__assign)({}, o);
var x = (0, tslib_1.__rest)(y, []);
var y = tslib_1.__assign({}, o);
var x = tslib_1.__rest(y, []);
//// [script.js]
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.f = void 0;
var tslib_1 = require("tslib");
function f() {
return (0, tslib_1.__asyncGenerator)(this, arguments, function f_1() {
return (0, tslib_1.__generator)(this, function (_a) {
return tslib_1.__asyncGenerator(this, arguments, function f_1() {
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, (0, tslib_1.__await)(1)];
case 0: return [4 /*yield*/, tslib_1.__await(1)];
case 1:
_a.sent();
return [4 /*yield*/, (0, tslib_1.__await)(2)];
return [4 /*yield*/, tslib_1.__await(2)];
case 2: return [4 /*yield*/, _a.sent()];
case 3:
_a.sent();
return [5 /*yield**/, (0, tslib_1.__values)((0, tslib_1.__asyncDelegator)((0, tslib_1.__asyncValues)([3])))];
return [5 /*yield**/, tslib_1.__values(tslib_1.__asyncDelegator(tslib_1.__asyncValues([3])))];
case 4: return [4 /*yield*/, tslib_1.__await.apply(void 0, [_a.sent()])];
case 5:
_a.sent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class Foo {
_Foo_field.set(this, true);
}
f() {
(0, tslib_1.__classPrivateFieldSet)(this, _Foo_field, (0, tslib_1.__classPrivateFieldGet)(this, _Foo_field, "f"), "f");
(0, tslib_1.__classPrivateFieldIn)(_Foo_field, this);
tslib_1.__classPrivateFieldSet(this, _Foo_field, tslib_1.__classPrivateFieldGet(this, _Foo_field, "f"), "f");
tslib_1.__classPrivateFieldIn(_Foo_field, this);
}
}
exports.Foo = Foo;
Expand Down
14 changes: 7 additions & 7 deletions tests/baselines/reference/importHelpersNoModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var A = /** @class */ (function () {
}());
exports.A = A;
var B = /** @class */ (function (_super) {
(0, tslib_1.__extends)(B, _super);
tslib_1.__extends(B, _super);
function B() {
return _super !== null && _super.apply(this, arguments) || this;
}
Expand All @@ -49,13 +49,13 @@ var C = /** @class */ (function () {
}
C.prototype.method = function (x) {
};
(0, tslib_1.__decorate)([
(0, tslib_1.__param)(0, dec),
(0, tslib_1.__metadata)("design:type", Function),
(0, tslib_1.__metadata)("design:paramtypes", [Number]),
(0, tslib_1.__metadata)("design:returntype", void 0)
tslib_1.__decorate([
tslib_1.__param(0, dec),
tslib_1.__metadata("design:type", Function),
tslib_1.__metadata("design:paramtypes", [Number]),
tslib_1.__metadata("design:returntype", void 0)
], C.prototype, "method", null);
C = (0, tslib_1.__decorate)([
C = tslib_1.__decorate([
dec
], C);
return C;
Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/importHelpersOutFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ define("b", ["require", "exports", "tslib", "a"], function (require, exports, ts
Object.defineProperty(exports, "__esModule", { value: true });
exports.B = void 0;
var B = /** @class */ (function (_super) {
(0, tslib_1.__extends)(B, _super);
tslib_1.__extends(B, _super);
function B() {
return _super !== null && _super.apply(this, arguments) || this;
}
Expand All @@ -50,7 +50,7 @@ define("c", ["require", "exports", "tslib", "a"], function (require, exports, ts
Object.defineProperty(exports, "__esModule", { value: true });
exports.C = void 0;
var C = /** @class */ (function (_super) {
(0, tslib_2.__extends)(C, _super);
tslib_2.__extends(C, _super);
function C() {
return _super !== null && _super.apply(this, arguments) || this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ define(["require", "exports", "tslib", "./a"], function (require, exports, tslib
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.a = void 0;
exports.a = (0, tslib_1.__importStar)(a);
exports.a = tslib_1.__importStar(a);
});
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ exports.A = A;
Object.defineProperty(exports, "__esModule", { value: true });
exports.a = void 0;
const tslib_1 = require("tslib");
exports.a = (0, tslib_1.__importStar)(require("./a"));
exports.a = tslib_1.__importStar(require("./a"));
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ define(["require", "exports", "tslib", "./a", "./a", "./a"], function (require,
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.a = exports.default = void 0;
a_3 = (0, tslib_1.__importDefault)(a_3);
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(a_1).default; } });
Object.defineProperty(exports, "a", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(a_2).default; } });
a_3 = tslib_1.__importDefault(a_3);
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return tslib_1.__importDefault(a_1).default; } });
Object.defineProperty(exports, "a", { enumerable: true, get: function () { return tslib_1.__importDefault(a_2).default; } });
void a_3.default;
});
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.a = exports.default = void 0;
const tslib_1 = require("tslib");
var a_1 = require("./a");
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(a_1).default; } });
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return tslib_1.__importDefault(a_1).default; } });
var a_2 = require("./a");
Object.defineProperty(exports, "a", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(a_2).default; } });
const a_3 = (0, tslib_1.__importDefault)(require("./a"));
Object.defineProperty(exports, "a", { enumerable: true, get: function () { return tslib_1.__importDefault(a_2).default; } });
const a_3 = tslib_1.__importDefault(require("./a"));
void a_3.default;
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ define(["require", "exports", "tslib", "./a"], function (require, exports, tslib
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.a = void 0;
a = (0, tslib_1.__importStar)(a);
a = tslib_1.__importStar(a);
exports.a = a;
});
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ exports.A = A;
Object.defineProperty(exports, "__esModule", { value: true });
exports.a = void 0;
const tslib_1 = require("tslib");
const a = (0, tslib_1.__importStar)(require("./a"));
const a = tslib_1.__importStar(require("./a"));
exports.a = a;
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ define(["require", "exports", "tslib"], function (require, exports, tslib_1) {
exports.A = void 0;
let A = class A {
};
A = (0, tslib_1.__decorate)([
A = tslib_1.__decorate([
dec
], A);
exports.A = A;
Expand Down
Loading

0 comments on commit 67f9895

Please sign in to comment.