From 07b68476c5527f611243e10b34aa3d341fda5f89 Mon Sep 17 00:00:00 2001 From: austaras Date: Wed, 1 Dec 2021 01:00:02 +0800 Subject: [PATCH] chore: Update tests --- .../input.ts/es5.1.normal/output.js | 4 +- .../input.ts/es5.1.normal/output.js | 4 +- .../input.ts/es5.1.normal/output.js | 4 +- .../input.ts/es5.1.normal/output.js | 4 +- .../input.ts/es5.1.normal/output.js | 4 +- .../input.ts/es5.1.normal/output.js | 4 +- .../input.ts/es5.1.normal/output.js | 4 +- .../input.ts/es5.2.minified/output.js | 4 +- .../input.ts/es5.1.normal/output.js | 4 +- .../input.ts/es5.2.minified/output.js | 4 +- .../input.ts/es5.1.normal/output.js | 12 +- .../input.ts/es5.2.minified/output.js | 10 +- .../input.ts/es5.1.normal/output.js | 12 +- .../input.ts/es5.2.minified/output.js | 10 +- .../input.ts/es5.1.normal/output.js | 6 +- .../input.ts/es5.2.minified/output.js | 15 +- .../input.ts/es5.1.normal/output.js | 12 +- .../input.ts/es5.2.minified/output.js | 13 +- .../input.ts/es5.1.normal/output.js | 12 +- .../input.ts/es5.2.minified/output.js | 12 +- .../input.ts/es5.1.normal/output.js | 12 +- .../input.ts/es5.2.minified/output.js | 14 +- .../input.ts/es5.1.normal/output.js | 4 +- .../input.ts/es5.1.normal/output.js | 4 +- .../input.ts/es5.1.normal/output.js | 4 +- .../input.ts/es5.2.minified/output.js | 4 +- .../input.ts/es5.1.normal/output.js | 4 +- .../input.ts/es5.2.minified/output.js | 3 +- .../input.ts/es5.1.normal/output.js | 4 +- .../input.ts/es5.2.minified/output.js | 3 +- .../input.ts/es5.1.normal/output.js | 6 +- .../input.ts/es5.2.minified/output.js | 10 +- .../input.ts/es5.1.normal/output.js | 6 +- .../input.ts/es5.2.minified/output.js | 10 +- .../input.ts/es5.1.normal/output.js | 6 +- .../input.ts/es5.2.minified/output.js | 3 +- .../input.ts/es5.1.normal/output.js | 16 +- .../input.ts/es5.1.normal/output.js | 16 +- .../input.ts/es5.1.normal/output.js | 28 +- .../input.ts/es5.2.minified/output.js | 6 +- .../input.ts/es5.1.normal/output.js | 28 +- .../input.ts/es5.2.minified/output.js | 6 +- .../input.ts/es5.1.normal/output.js | 16 +- .../input.ts/es5.1.normal/output.js | 16 +- .../input.ts/es5.1.normal/output.js | 28 +- .../input.ts/es5.2.minified/output.js | 23 +- .../input.ts/es5.1.normal/output.js | 28 +- .../input.ts/es5.2.minified/output.js | 23 +- .../input.ts/es5.1.normal/output.js | 52 ++-- .../input.ts/es5.2.minified/output.js | 39 ++- .../input.ts/es5.1.normal/output.js | 52 ++-- .../input.ts/es5.2.minified/output.js | 39 ++- .../input.ts/es5.1.normal/output.js | 48 +-- .../input.ts/es5.2.minified/output.js | 27 +- .../input.ts/es5.1.normal/output.js | 12 +- .../input.ts/es5.2.minified/output.js | 6 +- .../input.ts/es5.1.normal/output.js | 40 +-- .../input.ts/es5.2.minified/output.js | 40 +-- .../input.ts/es5.1.normal/output.js | 80 ++--- .../input.ts/es5.1.normal/output.js | 6 +- .../input.ts/es5.1.normal/output.js | 6 +- .../input.ts/es5.1.normal/output.js | 8 +- .../input.ts/es5.1.normal/output.js | 8 +- .../input.ts/es5.1.normal/output.js | 8 +- .../input.ts/es5.1.normal/output.js | 4 +- .../input.ts/es5.2.minified/output.js | 6 +- .../input.ts/es5.1.normal/output.js | 4 +- .../input.ts/es5.2.minified/output.js | 8 +- .../input.ts/es5.1.normal/output.js | 4 +- .../input.ts/es5.1.normal/output.js | 18 +- .../input.ts/es5.1.normal/output.js | 8 +- .../input.ts/es5.1.normal/output.js | 288 +++++++++--------- .../input.ts/es5.2.minified/output.js | 216 +++++++------ .../input.ts/es5.1.normal/output.js | 20 +- .../input.ts/es5.2.minified/output.js | 21 +- .../input.ts/es5.1.normal/output.js | 20 +- .../input.ts/es5.2.minified/output.js | 21 +- .../input.ts/es5.1.normal/output.js | 4 +- .../input.ts/es5.1.normal/output.js | 8 +- .../input.ts/es5.2.minified/output.js | 8 +- .../input.ts/es5.1.normal/output.js | 4 +- .../input.ts/es5.2.minified/output.js | 5 + .../input.ts/es5.1.normal/output.js | 4 +- .../input.ts/es5.2.minified/output.js | 6 +- .../input.ts/es5.1.normal/output.js | 8 +- .../input.ts/es5.2.minified/output.js | 8 +- .../input.ts/es5.1.normal/output.js | 4 +- .../input.ts/es5.2.minified/output.js | 5 + .../input.ts/es5.1.normal/output.js | 28 +- .../input.ts/es5.2.minified/output.js | 14 +- .../input.ts/es5.1.normal/output.js | 4 +- .../input.ts/es5.2.minified/output.js | 6 +- .../input.ts/es5.1.normal/output.js | 8 +- .../input.ts/es5.2.minified/output.js | 4 +- .../input.ts/es5.1.normal/output.js | 8 +- .../input.ts/es5.2.minified/output.js | 4 +- .../input.ts/es5.1.normal/output.js | 8 +- .../input.ts/es5.1.normal/output.js | 14 +- .../input.ts/es5.1.normal/output.js | 12 +- .../input.ts/es5.1.normal/output.js | 8 +- .../input.ts/es5.1.normal/output.js | 50 +-- .../input.ts/es5.2.minified/output.js | 9 +- .../input.ts/es5.1.normal/output.js | 36 +-- .../input.ts/es5.2.minified/output.js | 6 +- .../input.ts/es5.1.normal/output.js | 36 +-- .../input.ts/es5.2.minified/output.js | 6 +- .../input.ts/es5.1.normal/output.js | 4 +- .../input.ts/es5.1.normal/output.js | 4 +- .../input.ts/es5.2.minified/output.js | 4 +- .../input.ts/es5.1.normal/output.js | 4 +- .../input.ts/es5.2.minified/output.js | 4 +- .../input.ts/es5.1.normal/output.js | 4 +- .../input.ts/es5.1.normal/output.js | 8 +- .../input.ts/es5.1.normal/output.js | 4 +- .../input.ts/es5.2.minified/output.js | 5 +- .../input.ts/es5.1.normal/output.js | 4 +- .../input.ts/es5.2.minified/output.js | 5 +- .../input.ts/es5.1.normal/output.js | 12 +- .../input.ts/es5.2.minified/output.js | 12 +- .../input.ts/es5.1.normal/output.js | 12 +- .../input.ts/es5.2.minified/output.js | 12 +- .../input.ts/es5.1.normal/output.js | 6 +- .../input.ts/es5.1.normal/output.js | 28 +- .../input.ts/es5.1.normal/output.js | 4 +- .../input.ts/es5.1.normal/output.js | 12 +- .../input.ts/es5.2.minified/output.js | 5 +- .../input.ts/es5.1.normal/output.js | 12 +- .../input.ts/es5.2.minified/output.js | 5 +- .../witness/input.ts/es5.1.normal/output.js | 4 +- .../tests/es2015_destructuring.rs | 2 +- 130 files changed, 1127 insertions(+), 968 deletions(-) diff --git a/crates/swc/tests/tsc-references/async/es2017/asyncArrowFunction/asyncArrowFunction3_es2017/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/async/es2017/asyncArrowFunction/asyncArrowFunction3_es2017/input.ts/es5.1.normal/output.js index 83ad3ce4d411f..e53e88e0874de 100644 --- a/crates/swc/tests/tsc-references/async/es2017/asyncArrowFunction/asyncArrowFunction3_es2017/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/async/es2017/asyncArrowFunction/asyncArrowFunction3_es2017/input.ts/es5.1.normal/output.js @@ -1,5 +1,5 @@ // @target: es2017 // @noEmitHelpers: true -function f(param) { - var _await = param === void 0 ? _await : param; +function f() { + var _await = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : _await; } diff --git a/crates/swc/tests/tsc-references/async/es2017/functionDeclarations/asyncFunctionDeclaration3_es2017/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/async/es2017/functionDeclarations/asyncFunctionDeclaration3_es2017/input.ts/es5.1.normal/output.js index 83ad3ce4d411f..e53e88e0874de 100644 --- a/crates/swc/tests/tsc-references/async/es2017/functionDeclarations/asyncFunctionDeclaration3_es2017/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/async/es2017/functionDeclarations/asyncFunctionDeclaration3_es2017/input.ts/es5.1.normal/output.js @@ -1,5 +1,5 @@ // @target: es2017 // @noEmitHelpers: true -function f(param) { - var _await = param === void 0 ? _await : param; +function f() { + var _await = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : _await; } diff --git a/crates/swc/tests/tsc-references/async/es5/asyncArrowFunction/asyncArrowFunction3_es5/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/async/es5/asyncArrowFunction/asyncArrowFunction3_es5/input.ts/es5.1.normal/output.js index 18de63fecc747..0769cc49878e9 100644 --- a/crates/swc/tests/tsc-references/async/es5/asyncArrowFunction/asyncArrowFunction3_es5/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/async/es5/asyncArrowFunction/asyncArrowFunction3_es5/input.ts/es5.1.normal/output.js @@ -1,6 +1,6 @@ // @target: ES5 // @lib: es5,es2015.promise // @noEmitHelpers: true -function f(param) { - var _await = param === void 0 ? _await : param; +function f() { + var _await = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : _await; } diff --git a/crates/swc/tests/tsc-references/async/es5/functionDeclarations/asyncFunctionDeclaration3_es5/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/async/es5/functionDeclarations/asyncFunctionDeclaration3_es5/input.ts/es5.1.normal/output.js index 18de63fecc747..0769cc49878e9 100644 --- a/crates/swc/tests/tsc-references/async/es5/functionDeclarations/asyncFunctionDeclaration3_es5/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/async/es5/functionDeclarations/asyncFunctionDeclaration3_es5/input.ts/es5.1.normal/output.js @@ -1,6 +1,6 @@ // @target: ES5 // @lib: es5,es2015.promise // @noEmitHelpers: true -function f(param) { - var _await = param === void 0 ? _await : param; +function f() { + var _await = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : _await; } diff --git a/crates/swc/tests/tsc-references/async/es6/asyncArrowFunction/asyncArrowFunction3_es6/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/async/es6/asyncArrowFunction/asyncArrowFunction3_es6/input.ts/es5.1.normal/output.js index 82403eb44c8fd..604cf5644885d 100644 --- a/crates/swc/tests/tsc-references/async/es6/asyncArrowFunction/asyncArrowFunction3_es6/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/async/es6/asyncArrowFunction/asyncArrowFunction3_es6/input.ts/es5.1.normal/output.js @@ -1,5 +1,5 @@ // @target: ES6 // @noEmitHelpers: true -function f(param) { - var _await = param === void 0 ? _await : param; +function f() { + var _await = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : _await; } diff --git a/crates/swc/tests/tsc-references/async/es6/functionDeclarations/asyncFunctionDeclaration3_es6/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/async/es6/functionDeclarations/asyncFunctionDeclaration3_es6/input.ts/es5.1.normal/output.js index 82403eb44c8fd..604cf5644885d 100644 --- a/crates/swc/tests/tsc-references/async/es6/functionDeclarations/asyncFunctionDeclaration3_es6/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/async/es6/functionDeclarations/asyncFunctionDeclaration3_es6/input.ts/es5.1.normal/output.js @@ -1,5 +1,5 @@ // @target: ES6 // @noEmitHelpers: true -function f(param) { - var _await = param === void 0 ? _await : param; +function f() { + var _await = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : _await; } diff --git a/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.2/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.2/input.ts/es5.1.normal/output.js index ad2050f10b71e..92fec64d4c267 100644 --- a/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.2/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.2/input.ts/es5.1.normal/output.js @@ -88,7 +88,7 @@ var C = function C() { var C; })(); var x = ""; -(function(param, param1) { +(function(param) { var tmp = param[/*#__PURE__*/ (_class1 = function(C) { "use strict"; _inherits(_class, C); @@ -98,6 +98,6 @@ var x = ""; return _super.apply(this, arguments); } return _class; - }(C), _class1.x = 1, _class1).x], b = tmp === void 0 ? "" : tmp, d = param1 === void 0 ? x : param1; + }(C), _class1.x = 1, _class1).x], b = tmp === void 0 ? "" : tmp, d = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : x; var x1; })(); diff --git a/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.2/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.2/input.ts/es5.2.minified/output.js index 5191d851ffd97..adbc33a626344 100644 --- a/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.2/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.2/input.ts/es5.2.minified/output.js @@ -59,7 +59,7 @@ var _class, _class1, C = function() { } return _class; })(C)).x = 1, _class).x]; -}(), (function(param, param1) { +}(), (function(param) { (void 0)[((_class1 = (function(C) { "use strict"; _inherits(_class, C); @@ -68,5 +68,5 @@ var _class, _class1, C = function() { return _classCallCheck(this, _class), _super.apply(this, arguments); } return _class; - })(C)).x = 1, _class1).x]; + })(C)).x = 1, _class1).x], arguments.length > 1 && void 0 !== arguments[1] && arguments[1]; })(); diff --git a/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.3/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.3/input.ts/es5.1.normal/output.js index ad2050f10b71e..92fec64d4c267 100644 --- a/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.3/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.3/input.ts/es5.1.normal/output.js @@ -88,7 +88,7 @@ var C = function C() { var C; })(); var x = ""; -(function(param, param1) { +(function(param) { var tmp = param[/*#__PURE__*/ (_class1 = function(C) { "use strict"; _inherits(_class, C); @@ -98,6 +98,6 @@ var x = ""; return _super.apply(this, arguments); } return _class; - }(C), _class1.x = 1, _class1).x], b = tmp === void 0 ? "" : tmp, d = param1 === void 0 ? x : param1; + }(C), _class1.x = 1, _class1).x], b = tmp === void 0 ? "" : tmp, d = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : x; var x1; })(); diff --git a/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.3/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.3/input.ts/es5.2.minified/output.js index 5191d851ffd97..adbc33a626344 100644 --- a/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.3/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.3/input.ts/es5.2.minified/output.js @@ -59,7 +59,7 @@ var _class, _class1, C = function() { } return _class; })(C)).x = 1, _class).x]; -}(), (function(param, param1) { +}(), (function(param) { (void 0)[((_class1 = (function(C) { "use strict"; _inherits(_class, C); @@ -68,5 +68,5 @@ var _class, _class1, C = function() { return _classCallCheck(this, _class), _super.apply(this, arguments); } return _class; - })(C)).x = 1, _class1).x]; + })(C)).x = 1, _class1).x], arguments.length > 1 && void 0 !== arguments[1] && arguments[1]; })(); diff --git a/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterInitializer.2/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterInitializer.2/input.ts/es5.1.normal/output.js index 72926a964b024..f72c4da64cadb 100644 --- a/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterInitializer.2/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterInitializer.2/input.ts/es5.1.normal/output.js @@ -74,8 +74,8 @@ var C = function C() { "use strict"; _classCallCheck(this, C); }; -(function(param) { - var b = param === void 0 ? (_class2 = /*#__PURE__*/ function(C) { +(function() { + var b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : (_class2 = /*#__PURE__*/ function(C) { "use strict"; _inherits(_class, C); var _super = _createSuper(_class); @@ -84,12 +84,12 @@ var C = function C() { return _super.apply(this, arguments); } return _class; - }(C), _class2.x = 1, _class2) : param; + }(C), _class2.x = 1, _class2); var C1; })(); var x = ""; -(function(param, param1) { - var b = param === void 0 ? (_class1 = /*#__PURE__*/ function(C) { +(function() { + var b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : (_class1 = /*#__PURE__*/ function(C) { "use strict"; _inherits(_class, C); var _super = _createSuper(_class); @@ -98,6 +98,6 @@ var x = ""; return _super.apply(this, arguments); } return _class; - }(C), _class1.x = 1, _class1) : param, d = param1 === void 0 ? x : param1; + }(C), _class1.x = 1, _class1), d = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : x; var x1; })(); diff --git a/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterInitializer.2/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterInitializer.2/input.ts/es5.2.minified/output.js index dea616a84e18a..bcdf6866e90df 100644 --- a/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterInitializer.2/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterInitializer.2/input.ts/es5.2.minified/output.js @@ -49,8 +49,8 @@ var _class2, _class1, C1 = function() { "use strict"; _classCallCheck(this, C1); }; -!function(param) { - (_class2 = (function(C) { +!function() { + arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : (_class2 = (function(C) { "use strict"; _inherits(_class, C); var _super = _createSuper(_class); @@ -59,8 +59,8 @@ var _class2, _class1, C1 = function() { } return _class; })(C1)).x = 1; -}(), (function(param, param1) { - (_class1 = (function(C) { +}(), (function() { + arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : (_class1 = (function(C) { "use strict"; _inherits(_class, C); var _super = _createSuper(_class); @@ -68,5 +68,5 @@ var _class2, _class1, C1 = function() { return _classCallCheck(this, _class), _super.apply(this, arguments); } return _class; - })(C1)).x = 1; + })(C1)).x = 1, arguments.length > 1 && void 0 !== arguments[1] && arguments[1]; })(); diff --git a/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterInitializer.3/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterInitializer.3/input.ts/es5.1.normal/output.js index 72926a964b024..f72c4da64cadb 100644 --- a/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterInitializer.3/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterInitializer.3/input.ts/es5.1.normal/output.js @@ -74,8 +74,8 @@ var C = function C() { "use strict"; _classCallCheck(this, C); }; -(function(param) { - var b = param === void 0 ? (_class2 = /*#__PURE__*/ function(C) { +(function() { + var b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : (_class2 = /*#__PURE__*/ function(C) { "use strict"; _inherits(_class, C); var _super = _createSuper(_class); @@ -84,12 +84,12 @@ var C = function C() { return _super.apply(this, arguments); } return _class; - }(C), _class2.x = 1, _class2) : param; + }(C), _class2.x = 1, _class2); var C1; })(); var x = ""; -(function(param, param1) { - var b = param === void 0 ? (_class1 = /*#__PURE__*/ function(C) { +(function() { + var b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : (_class1 = /*#__PURE__*/ function(C) { "use strict"; _inherits(_class, C); var _super = _createSuper(_class); @@ -98,6 +98,6 @@ var x = ""; return _super.apply(this, arguments); } return _class; - }(C), _class1.x = 1, _class1) : param, d = param1 === void 0 ? x : param1; + }(C), _class1.x = 1, _class1), d = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : x; var x1; })(); diff --git a/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterInitializer.3/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterInitializer.3/input.ts/es5.2.minified/output.js index dea616a84e18a..bcdf6866e90df 100644 --- a/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterInitializer.3/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterInitializer.3/input.ts/es5.2.minified/output.js @@ -49,8 +49,8 @@ var _class2, _class1, C1 = function() { "use strict"; _classCallCheck(this, C1); }; -!function(param) { - (_class2 = (function(C) { +!function() { + arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : (_class2 = (function(C) { "use strict"; _inherits(_class, C); var _super = _createSuper(_class); @@ -59,8 +59,8 @@ var _class2, _class1, C1 = function() { } return _class; })(C1)).x = 1; -}(), (function(param, param1) { - (_class1 = (function(C) { +}(), (function() { + arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : (_class1 = (function(C) { "use strict"; _inherits(_class, C); var _super = _createSuper(_class); @@ -68,5 +68,5 @@ var _class2, _class1, C1 = function() { return _classCallCheck(this, _class), _super.apply(this, arguments); } return _class; - })(C1)).x = 1; + })(C1)).x = 1, arguments.length > 1 && void 0 !== arguments[1] && arguments[1]; })(); diff --git a/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterInitializer/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterInitializer/input.ts/es5.1.normal/output.js index dc3b6e9ace2f0..a168e654defd7 100644 --- a/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterInitializer/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterInitializer/input.ts/es5.1.normal/output.js @@ -7,9 +7,9 @@ var _class1; // @target: esnext,es2015,es5 // @noTypesAndSymbols: true // https://github.com/microsoft/TypeScript/issues/36295 -(function(param) { - var b = param === void 0 ? (_class1 = function _class() { +(function() { + var b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : (_class1 = function _class() { "use strict"; _classCallCheck(this, _class); - }, _class1.x = 1, _class1) : param; + }, _class1.x = 1, _class1); })(); diff --git a/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterInitializer/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterInitializer/input.ts/es5.2.minified/output.js index a86656b5e4100..d7d9d0c2f56cd 100644 --- a/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterInitializer/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/classes/classExpressions/classWithStaticFieldInParameterInitializer/input.ts/es5.2.minified/output.js @@ -1,6 +1,9 @@ -(function _class() { - "use strict"; - !function(instance, Constructor) { - if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function"); - }(this, _class); -}).x = 1; +var _class1; +!function() { + arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : (_class1 = function _class() { + "use strict"; + !function(instance, Constructor) { + if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function"); + }(this, _class); + }).x = 1; +}(); diff --git a/crates/swc/tests/tsc-references/classes/constructorDeclarations/constructorParameters/constructorDefaultValuesReferencingThis/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/classes/constructorDeclarations/constructorParameters/constructorDefaultValuesReferencingThis/input.ts/es5.1.normal/output.js index 57e9d60a8efa3..aa056bced76bc 100644 --- a/crates/swc/tests/tsc-references/classes/constructorDeclarations/constructorParameters/constructorDefaultValuesReferencingThis/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/classes/constructorDeclarations/constructorParameters/constructorDefaultValuesReferencingThis/input.ts/es5.1.normal/output.js @@ -3,19 +3,19 @@ function _classCallCheck(instance, Constructor) { throw new TypeError("Cannot call a class as a function"); } } -var C = function C(param) { +var C = function C() { "use strict"; - var x = param === void 0 ? this : param; + var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this; _classCallCheck(this, C); }; -var D = function D(param) { +var D = function D() { "use strict"; - var x = param === void 0 ? this : param; + var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this; _classCallCheck(this, D); }; -var E = function E(param) { +var E = function E() { "use strict"; - var x = param === void 0 ? this : param; + var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this; _classCallCheck(this, E); this.x = x; }; diff --git a/crates/swc/tests/tsc-references/classes/constructorDeclarations/constructorParameters/constructorDefaultValuesReferencingThis/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/classes/constructorDeclarations/constructorParameters/constructorDefaultValuesReferencingThis/input.ts/es5.2.minified/output.js index e6669e223f25a..1c0bea6a2748c 100644 --- a/crates/swc/tests/tsc-references/classes/constructorDeclarations/constructorParameters/constructorDefaultValuesReferencingThis/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/classes/constructorDeclarations/constructorParameters/constructorDefaultValuesReferencingThis/input.ts/es5.2.minified/output.js @@ -1,13 +1,14 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function"); } -var C = function(param) { +var C = function() { "use strict"; - _classCallCheck(this, C); -}, D = function(param) { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0], _classCallCheck(this, C); +}, D = function() { "use strict"; - _classCallCheck(this, D); -}, E = function(param) { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0], _classCallCheck(this, D); +}, E = function() { "use strict"; - _classCallCheck(this, E), this.x = void 0 === param ? this : param; + var x = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : this; + _classCallCheck(this, E), this.x = x; }; diff --git a/crates/swc/tests/tsc-references/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues/input.ts/es5.1.normal/output.js index 45d4bc01bd7e5..cfce54bf45d5c 100644 --- a/crates/swc/tests/tsc-references/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues/input.ts/es5.1.normal/output.js @@ -3,21 +3,21 @@ function _classCallCheck(instance, Constructor) { throw new TypeError("Cannot call a class as a function"); } } -var C = function C(param) { +var C = function C() { "use strict"; - var x = param === void 0 ? 1 : param; + var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 1; _classCallCheck(this, C); var y = x; }; -var D = function D(param) { +var D = function D() { "use strict"; - var x = param === void 0 ? null : param; + var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : null; _classCallCheck(this, D); var y = x; }; -var E = function E(param) { +var E = function E() { "use strict"; - var x = param === void 0 ? null : param; + var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : null; _classCallCheck(this, E); var y = x; }; diff --git a/crates/swc/tests/tsc-references/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues/input.ts/es5.2.minified/output.js index 38bd4579f874a..0faf788e9fe1d 100644 --- a/crates/swc/tests/tsc-references/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues/input.ts/es5.2.minified/output.js @@ -1,13 +1,13 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function"); } -var C = function(param) { +var C = function() { "use strict"; - _classCallCheck(this, C), void 0 === param; -}, D = function(param) { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0], _classCallCheck(this, C); +}, D = function() { "use strict"; - _classCallCheck(this, D), void 0 === param; -}, E = function(param) { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0], _classCallCheck(this, D); +}, E = function() { "use strict"; - _classCallCheck(this, E), void 0 === param; + arguments.length > 0 && void 0 !== arguments[0] && arguments[0], _classCallCheck(this, E); }; diff --git a/crates/swc/tests/tsc-references/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues2/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues2/input.ts/es5.1.normal/output.js index 43de0b34fe7d4..90ceb50bdd250 100644 --- a/crates/swc/tests/tsc-references/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues2/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues2/input.ts/es5.1.normal/output.js @@ -3,23 +3,23 @@ function _classCallCheck(instance, Constructor) { throw new TypeError("Cannot call a class as a function"); } } -var C = function C(param) { +var C = function C() { "use strict"; - var x = param === void 0 ? 1 : param; + var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 1; _classCallCheck(this, C); this.x = x; var y = x; }; -var D = function D(param, param1) { +var D = function D() { "use strict"; - var x = param === void 0 ? 1 : param, y = param1 === void 0 ? x : param1; + var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 1, y = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : x; _classCallCheck(this, D); this.y = y; var z = x; }; -var E = function E(param) { +var E = function E() { "use strict"; - var x = param === void 0 ? new Date() : param; + var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : new Date(); _classCallCheck(this, E); var y = x; }; diff --git a/crates/swc/tests/tsc-references/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues2/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues2/input.ts/es5.2.minified/output.js index 507ea3550cef2..f864ea2e3e471 100644 --- a/crates/swc/tests/tsc-references/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues2/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues2/input.ts/es5.2.minified/output.js @@ -1,13 +1,15 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function"); } -var C = function(param) { +var C = function() { "use strict"; - _classCallCheck(this, C), this.x = void 0 === param ? 1 : param; -}, D = function(param, param1) { + var x = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 1; + _classCallCheck(this, C), this.x = x; +}, D = function() { "use strict"; - _classCallCheck(this, D), this.y = void 0 === param1 && void 0 === param ? 1 : param; -}, E = function(param) { + var x = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 1, y = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : x; + _classCallCheck(this, D), this.y = y; +}, E = function() { "use strict"; - void 0 === param && new Date(), _classCallCheck(this, E); + arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : new Date(), _classCallCheck(this, E); }; diff --git a/crates/swc/tests/tsc-references/es6/arrowFunction/emitArrowFunction/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/es6/arrowFunction/emitArrowFunction/input.ts/es5.1.normal/output.js index 73a74627dbfb9..4c35d48b42244 100644 --- a/crates/swc/tests/tsc-references/es6/arrowFunction/emitArrowFunction/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/es6/arrowFunction/emitArrowFunction/input.ts/es5.1.normal/output.js @@ -8,8 +8,8 @@ var f3 = function(x, y) { rest[_key - 2] = arguments[_key]; } }; -var f4 = function(x, y, param) { - var z = param === void 0 ? 10 : param; +var f4 = function(x, y) { + var z = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 10; }; function foo(func) { } diff --git a/crates/swc/tests/tsc-references/es6/arrowFunction/emitArrowFunctionES6/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/es6/arrowFunction/emitArrowFunctionES6/input.ts/es5.1.normal/output.js index c467fc3d3d7f7..5b8c471a00eb5 100644 --- a/crates/swc/tests/tsc-references/es6/arrowFunction/emitArrowFunctionES6/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/es6/arrowFunction/emitArrowFunctionES6/input.ts/es5.1.normal/output.js @@ -45,8 +45,8 @@ var f3 = function(x, y) { rest[_key - 2] = arguments[_key]; } }; -var f4 = function(x, y, param) { - var z = param === void 0 ? 10 : param; +var f4 = function(x, y) { + var z = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 10; }; function foo(func) { } diff --git a/crates/swc/tests/tsc-references/es6/classDeclaration/emitClassDeclarationOverloadInES6/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/es6/classDeclaration/emitClassDeclarationOverloadInES6/input.ts/es5.1.normal/output.js index ac5109b9f162d..87263c70204ea 100644 --- a/crates/swc/tests/tsc-references/es6/classDeclaration/emitClassDeclarationOverloadInES6/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/es6/classDeclaration/emitClassDeclarationOverloadInES6/input.ts/es5.1.normal/output.js @@ -7,8 +7,8 @@ var C = function C(x) { "use strict"; _classCallCheck(this, C); }; -var D = function D(x, param) { +var D = function D(x) { "use strict"; - var z = param === void 0 ? "hello" : param; + var z = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "hello"; _classCallCheck(this, D); }; diff --git a/crates/swc/tests/tsc-references/es6/classDeclaration/emitClassDeclarationOverloadInES6/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/es6/classDeclaration/emitClassDeclarationOverloadInES6/input.ts/es5.2.minified/output.js index b3f34e8edb1f5..cd12dde0a0d65 100644 --- a/crates/swc/tests/tsc-references/es6/classDeclaration/emitClassDeclarationOverloadInES6/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/es6/classDeclaration/emitClassDeclarationOverloadInES6/input.ts/es5.2.minified/output.js @@ -4,7 +4,7 @@ function _classCallCheck(instance, Constructor) { var C = function(x) { "use strict"; _classCallCheck(this, C); -}, D = function(x, param) { +}, D = function(x) { "use strict"; - _classCallCheck(this, D); + arguments.length > 1 && void 0 !== arguments[1] && arguments[1], _classCallCheck(this, D); }; diff --git a/crates/swc/tests/tsc-references/es6/classDeclaration/emitClassDeclarationWithConstructorInES6/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/es6/classDeclaration/emitClassDeclarationWithConstructorInES6/input.ts/es5.1.normal/output.js index b7c3dda9f7e1b..6bb2f50323875 100644 --- a/crates/swc/tests/tsc-references/es6/classDeclaration/emitClassDeclarationWithConstructorInES6/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/es6/classDeclaration/emitClassDeclarationWithConstructorInES6/input.ts/es5.1.normal/output.js @@ -34,8 +34,8 @@ var A = // @target: es6 }(); var B = /*#__PURE__*/ function() { "use strict"; - function B(x, param) { - var z = param === void 0 ? "hello" : param; + function B(x) { + var z = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "hello"; for(var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){ args[_key - 2] = arguments[_key]; } diff --git a/crates/swc/tests/tsc-references/es6/classDeclaration/emitClassDeclarationWithConstructorInES6/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/es6/classDeclaration/emitClassDeclarationWithConstructorInES6/input.ts/es5.2.minified/output.js index 04d8dce037184..eaa08119ac77b 100644 --- a/crates/swc/tests/tsc-references/es6/classDeclaration/emitClassDeclarationWithConstructorInES6/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/es6/classDeclaration/emitClassDeclarationWithConstructorInES6/input.ts/es5.2.minified/output.js @@ -24,7 +24,8 @@ var A = function() { ]), A; }(), B = function() { "use strict"; - function B(x, param) { + function B(x) { + arguments.length > 1 && void 0 !== arguments[1] && arguments[1]; for(var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++)args[_key - 2] = arguments[_key]; _classCallCheck(this, B), this.x = "hello", this.y = 10; } diff --git a/crates/swc/tests/tsc-references/es6/classDeclaration/emitClassDeclarationWithExtensionInES6/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/es6/classDeclaration/emitClassDeclarationWithExtensionInES6/input.ts/es5.1.normal/output.js index 93e27d8db6361..b917052ea5dcc 100644 --- a/crates/swc/tests/tsc-references/es6/classDeclaration/emitClassDeclarationWithExtensionInES6/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/es6/classDeclaration/emitClassDeclarationWithExtensionInES6/input.ts/es5.1.normal/output.js @@ -115,8 +115,8 @@ var B = // @target: es6 _createClass(B, [ { key: "baz", - value: function baz(a, param) { - var y = param === void 0 ? 10 : param; + value: function baz(a) { + var y = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 10; } } ]); diff --git a/crates/swc/tests/tsc-references/es6/classDeclaration/emitClassDeclarationWithExtensionInES6/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/es6/classDeclaration/emitClassDeclarationWithExtensionInES6/input.ts/es5.2.minified/output.js index c9715a444db42..03a6c24cf64f4 100644 --- a/crates/swc/tests/tsc-references/es6/classDeclaration/emitClassDeclarationWithExtensionInES6/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/es6/classDeclaration/emitClassDeclarationWithExtensionInES6/input.ts/es5.2.minified/output.js @@ -75,7 +75,8 @@ var B = function() { return _createClass(B, [ { key: "baz", - value: function(a, param) { + value: function(a) { + arguments.length > 1 && void 0 !== arguments[1] && arguments[1]; } } ]), B; diff --git a/crates/swc/tests/tsc-references/es6/classExpressions/typeArgumentInferenceWithClassExpression1/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/es6/classExpressions/typeArgumentInferenceWithClassExpression1/input.ts/es5.1.normal/output.js index db51119607cc8..f26f248af0d4f 100644 --- a/crates/swc/tests/tsc-references/es6/classExpressions/typeArgumentInferenceWithClassExpression1/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/es6/classExpressions/typeArgumentInferenceWithClassExpression1/input.ts/es5.1.normal/output.js @@ -4,11 +4,11 @@ function _classCallCheck(instance, Constructor) { } } var _class1; -function foo(param) { - var x = param === void 0 ? function _class() { +function foo() { + var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function _class() { "use strict"; _classCallCheck(this, _class); - } : param; + }; return undefined; } foo((_class1 = function _class() { diff --git a/crates/swc/tests/tsc-references/es6/classExpressions/typeArgumentInferenceWithClassExpression1/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/es6/classExpressions/typeArgumentInferenceWithClassExpression1/input.ts/es5.2.minified/output.js index d89da0b59c9ed..58da6c55a7f44 100644 --- a/crates/swc/tests/tsc-references/es6/classExpressions/typeArgumentInferenceWithClassExpression1/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/es6/classExpressions/typeArgumentInferenceWithClassExpression1/input.ts/es5.2.minified/output.js @@ -1 +1,9 @@ -(void 0).length; +var _class1; +(function() { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0]; +})(((_class1 = function _class() { + "use strict"; + (function(instance, Constructor) { + if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function"); + })(this, _class); +}).prop = "hello", _class1)).length; diff --git a/crates/swc/tests/tsc-references/es6/classExpressions/typeArgumentInferenceWithClassExpression2/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/es6/classExpressions/typeArgumentInferenceWithClassExpression2/input.ts/es5.1.normal/output.js index 22b6bace63bcb..3908fe370acc8 100644 --- a/crates/swc/tests/tsc-references/es6/classExpressions/typeArgumentInferenceWithClassExpression2/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/es6/classExpressions/typeArgumentInferenceWithClassExpression2/input.ts/es5.1.normal/output.js @@ -4,11 +4,11 @@ function _classCallCheck(instance, Constructor) { } } var _class1; -function foo(param) { - var x = param === void 0 ? function _class() { +function foo() { + var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function _class() { "use strict"; _classCallCheck(this, _class); - } : param; + }; return undefined; } // Should not infer string because it is a static property diff --git a/crates/swc/tests/tsc-references/es6/classExpressions/typeArgumentInferenceWithClassExpression2/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/es6/classExpressions/typeArgumentInferenceWithClassExpression2/input.ts/es5.2.minified/output.js index d89da0b59c9ed..58da6c55a7f44 100644 --- a/crates/swc/tests/tsc-references/es6/classExpressions/typeArgumentInferenceWithClassExpression2/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/es6/classExpressions/typeArgumentInferenceWithClassExpression2/input.ts/es5.2.minified/output.js @@ -1 +1,9 @@ -(void 0).length; +var _class1; +(function() { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0]; +})(((_class1 = function _class() { + "use strict"; + (function(instance, Constructor) { + if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function"); + })(this, _class); +}).prop = "hello", _class1)).length; diff --git a/crates/swc/tests/tsc-references/es6/classExpressions/typeArgumentInferenceWithClassExpression3/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/es6/classExpressions/typeArgumentInferenceWithClassExpression3/input.ts/es5.1.normal/output.js index 3da8f5040cb27..a912a0caa060e 100644 --- a/crates/swc/tests/tsc-references/es6/classExpressions/typeArgumentInferenceWithClassExpression3/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/es6/classExpressions/typeArgumentInferenceWithClassExpression3/input.ts/es5.1.normal/output.js @@ -3,11 +3,11 @@ function _classCallCheck(instance, Constructor) { throw new TypeError("Cannot call a class as a function"); } } -function foo(param) { - var x = param === void 0 ? function _class() { +function foo() { + var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function _class() { "use strict"; _classCallCheck(this, _class); - } : param; + }; return undefined; } foo(function _class() { diff --git a/crates/swc/tests/tsc-references/es6/classExpressions/typeArgumentInferenceWithClassExpression3/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/es6/classExpressions/typeArgumentInferenceWithClassExpression3/input.ts/es5.2.minified/output.js index 9314de0281b83..8364958f66550 100644 --- a/crates/swc/tests/tsc-references/es6/classExpressions/typeArgumentInferenceWithClassExpression3/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/es6/classExpressions/typeArgumentInferenceWithClassExpression3/input.ts/es5.2.minified/output.js @@ -1,4 +1,5 @@ -(function(param) { +(function() { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0]; })(function _class() { "use strict"; (function(instance, Constructor) { diff --git a/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersFunction/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersFunction/input.ts/es5.1.normal/output.js index 180bee3ca3cf4..83aee96655fcf 100644 --- a/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersFunction/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersFunction/input.ts/es5.1.normal/output.js @@ -1,18 +1,18 @@ // @target: es5 -function foo(x, param) { - var y = param === void 0 ? 10 : param; +function foo(x) { + var y = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 10; } -function baz(x, param) { - var y = param === void 0 ? 5 : param; +function baz(x) { + var y = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 5; for(var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){ rest[_key - 2] = arguments[_key]; } } -function bar(param) { - var y = param === void 0 ? 10 : param; +function bar() { + var y = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 10; } -function bar1(param) { - var y = param === void 0 ? 10 : param; +function bar1() { + var y = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 10; for(var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){ rest[_key - 1] = arguments[_key]; } diff --git a/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersFunctionES6/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersFunctionES6/input.ts/es5.1.normal/output.js index 63c8547a62100..ca6936257f932 100644 --- a/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersFunctionES6/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersFunctionES6/input.ts/es5.1.normal/output.js @@ -1,18 +1,18 @@ // @target:es6 -function foo(x, param) { - var y = param === void 0 ? 10 : param; +function foo(x) { + var y = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 10; } -function baz(x, param) { - var y = param === void 0 ? 5 : param; +function baz(x) { + var y = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 5; for(var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){ rest[_key - 2] = arguments[_key]; } } -function bar(param) { - var y = param === void 0 ? 10 : param; +function bar() { + var y = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 10; } -function bar1(param) { - var y = param === void 0 ? 10 : param; +function bar1() { + var y = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 10; for(var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){ rest[_key - 1] = arguments[_key]; } diff --git a/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersFunctionExpression/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersFunctionExpression/input.ts/es5.1.normal/output.js index a339e338f507f..028bba7a8c878 100644 --- a/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersFunctionExpression/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersFunctionExpression/input.ts/es5.1.normal/output.js @@ -1,36 +1,36 @@ // @target: es5 -var lambda1 = function(param) { - var y = param === void 0 ? "hello" : param; +var lambda1 = function() { + var y = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "hello"; }; -var lambda2 = function(x, param) { - var y = param === void 0 ? "hello" : param; +var lambda2 = function(x) { + var y = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "hello"; }; -var lambda3 = function(x, param) { - var y = param === void 0 ? "hello" : param; +var lambda3 = function(x) { + var y = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "hello"; for(var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){ rest[_key - 2] = arguments[_key]; } }; -var lambda4 = function(param) { - var y = param === void 0 ? "hello" : param; +var lambda4 = function() { + var y = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "hello"; for(var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){ rest[_key - 1] = arguments[_key]; } }; -var x = function x(param) { - var str = param === void 0 ? "hello" : param; +var x = function x() { + var str = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "hello"; for(var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){ rest[_key - 1] = arguments[_key]; } }; -var y = function(param, param1) { - var num = param === void 0 ? 10 : param, boo = param1 === void 0 ? false : param1; +var y = function() { + var num = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 10, boo = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false; for(var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){ rest[_key - 2] = arguments[_key]; } }(); -var z = function(num, param) { - var boo = param === void 0 ? false : param; +var z = function(num) { + var boo = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false; for(var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){ rest[_key - 2] = arguments[_key]; } diff --git a/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersFunctionExpression/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersFunctionExpression/input.ts/es5.2.minified/output.js index 0ca52c91a7739..6da3da578200b 100644 --- a/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersFunctionExpression/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersFunctionExpression/input.ts/es5.2.minified/output.js @@ -1,5 +1,7 @@ -!function(param, param1) { +!function() { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0], arguments.length > 1 && void 0 !== arguments[1] && arguments[1]; for(var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++)rest[_key - 2] = arguments[_key]; -}(), (function(num, param) { +}(), (function(num) { + arguments.length > 1 && void 0 !== arguments[1] && arguments[1]; for(var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++)rest[_key - 2] = arguments[_key]; })(10); diff --git a/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersFunctionExpressionES6/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersFunctionExpressionES6/input.ts/es5.1.normal/output.js index cb54b8bb0a3f8..f4878745a3026 100644 --- a/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersFunctionExpressionES6/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersFunctionExpressionES6/input.ts/es5.1.normal/output.js @@ -1,36 +1,36 @@ // @target:es6 -var lambda1 = function(param) { - var y = param === void 0 ? "hello" : param; +var lambda1 = function() { + var y = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "hello"; }; -var lambda2 = function(x, param) { - var y = param === void 0 ? "hello" : param; +var lambda2 = function(x) { + var y = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "hello"; }; -var lambda3 = function(x, param) { - var y = param === void 0 ? "hello" : param; +var lambda3 = function(x) { + var y = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "hello"; for(var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){ rest[_key - 2] = arguments[_key]; } }; -var lambda4 = function(param) { - var y = param === void 0 ? "hello" : param; +var lambda4 = function() { + var y = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "hello"; for(var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){ rest[_key - 1] = arguments[_key]; } }; -var x = function x(param) { - var str = param === void 0 ? "hello" : param; +var x = function x() { + var str = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "hello"; for(var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){ rest[_key - 1] = arguments[_key]; } }; -var y = function(param, param1) { - var num = param === void 0 ? 10 : param, boo = param1 === void 0 ? false : param1; +var y = function() { + var num = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 10, boo = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false; for(var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){ rest[_key - 2] = arguments[_key]; } }(); -var z = function(num, param) { - var boo = param === void 0 ? false : param; +var z = function(num) { + var boo = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false; for(var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){ rest[_key - 2] = arguments[_key]; } diff --git a/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersFunctionExpressionES6/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersFunctionExpressionES6/input.ts/es5.2.minified/output.js index 0ca52c91a7739..6da3da578200b 100644 --- a/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersFunctionExpressionES6/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersFunctionExpressionES6/input.ts/es5.2.minified/output.js @@ -1,5 +1,7 @@ -!function(param, param1) { +!function() { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0], arguments.length > 1 && void 0 !== arguments[1] && arguments[1]; for(var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++)rest[_key - 2] = arguments[_key]; -}(), (function(num, param) { +}(), (function(num) { + arguments.length > 1 && void 0 !== arguments[1] && arguments[1]; for(var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++)rest[_key - 2] = arguments[_key]; })(10); diff --git a/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersFunctionProperty/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersFunctionProperty/input.ts/es5.1.normal/output.js index fec45f274dfae..2be41cf14d3ee 100644 --- a/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersFunctionProperty/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersFunctionProperty/input.ts/es5.1.normal/output.js @@ -1,19 +1,19 @@ // @target: es5 var obj2 = { - func1: function(param) { - var y = param === void 0 ? 10 : param; + func1: function() { + var y = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 10; for(var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){ rest[_key - 1] = arguments[_key]; } }, - func2: function(param) { - var x = param === void 0 ? "hello" : param; + func2: function() { + var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "hello"; }, - func3: function(x, z, param) { - var y = param === void 0 ? "hello" : param; + func3: function(x, z) { + var y = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "hello"; }, - func4: function(x, z, param) { - var y = param === void 0 ? "hello" : param; + func4: function(x, z) { + var y = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "hello"; for(var _len = arguments.length, rest = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++){ rest[_key - 3] = arguments[_key]; } diff --git a/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersFunctionPropertyES6/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersFunctionPropertyES6/input.ts/es5.1.normal/output.js index b7b1c406d3c90..f8d125766f603 100644 --- a/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersFunctionPropertyES6/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersFunctionPropertyES6/input.ts/es5.1.normal/output.js @@ -1,19 +1,19 @@ // @target:es6 var obj2 = { - func1: function(param) { - var y = param === void 0 ? 10 : param; + func1: function() { + var y = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 10; for(var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){ rest[_key - 1] = arguments[_key]; } }, - func2: function(param) { - var x = param === void 0 ? "hello" : param; + func2: function() { + var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "hello"; }, - func3: function(x, z, param) { - var y = param === void 0 ? "hello" : param; + func3: function(x, z) { + var y = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "hello"; }, - func4: function(x, z, param) { - var y = param === void 0 ? "hello" : param; + func4: function(x, z) { + var y = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "hello"; for(var _len = arguments.length, rest = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++){ rest[_key - 3] = arguments[_key]; } diff --git a/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersMethod/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersMethod/input.ts/es5.1.normal/output.js index f4825e54e6616..e0a9d4a875e60 100644 --- a/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersMethod/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersMethod/input.ts/es5.1.normal/output.js @@ -20,21 +20,21 @@ function _createClass(Constructor, protoProps, staticProps) { var C = // @target: es5 /*#__PURE__*/ function() { "use strict"; - function C(t, z, x, param) { - var y = param === void 0 ? "hello" : param; + function C(t, z, x) { + var y = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "hello"; _classCallCheck(this, C); } _createClass(C, [ { key: "foo", - value: function foo(x, param) { - var t = param === void 0 ? false : param; + value: function foo(x) { + var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false; } }, { key: "foo1", - value: function foo1(x, param) { - var t = param === void 0 ? false : param; + value: function foo1(x) { + var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false; for(var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){ rest[_key - 2] = arguments[_key]; } @@ -42,14 +42,14 @@ var C = // @target: es5 }, { key: "bar", - value: function bar(param) { - var t = param === void 0 ? false : param; + value: function bar() { + var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false; } }, { key: "boo", - value: function boo(param) { - var t = param === void 0 ? false : param; + value: function boo() { + var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false; for(var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){ rest[_key - 1] = arguments[_key]; } @@ -58,14 +58,14 @@ var C = // @target: es5 ]); return C; }(); -var D = function D(param) { +var D = function D() { "use strict"; - var y = param === void 0 ? "hello" : param; + var y = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "hello"; _classCallCheck(this, D); }; -var E = function E(param) { +var E = function E() { "use strict"; - var y = param === void 0 ? "hello" : param; + var y = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "hello"; for(var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){ rest[_key - 1] = arguments[_key]; } diff --git a/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersMethod/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersMethod/input.ts/es5.2.minified/output.js index 9273f9a6e8a7d..ebdd5a7978b94 100644 --- a/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersMethod/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersMethod/input.ts/es5.2.minified/output.js @@ -10,38 +10,43 @@ function _defineProperties(target, props) { var C = function() { "use strict"; var Constructor, protoProps, staticProps; - function C(t, z, x, param) { - _classCallCheck(this, C); + function C(t, z, x) { + arguments.length > 3 && void 0 !== arguments[3] && arguments[3], _classCallCheck(this, C); } return Constructor = C, protoProps = [ { key: "foo", - value: function(x, param) { + value: function(x) { + arguments.length > 1 && void 0 !== arguments[1] && arguments[1]; } }, { key: "foo1", - value: function(x, param) { + value: function(x) { + arguments.length > 1 && void 0 !== arguments[1] && arguments[1]; for(var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++)rest[_key - 2] = arguments[_key]; } }, { key: "bar", - value: function(param) { + value: function() { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0]; } }, { key: "boo", - value: function(param) { + value: function() { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0]; for(var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++)rest[_key - 1] = arguments[_key]; } } ], _defineProperties(Constructor.prototype, protoProps), staticProps && _defineProperties(Constructor, staticProps), C; -}(), D = function(param) { +}(), D = function() { "use strict"; - _classCallCheck(this, D); -}, E = function(param) { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0], _classCallCheck(this, D); +}, E = function() { "use strict"; + arguments.length > 0 && void 0 !== arguments[0] && arguments[0]; for(var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++)rest[_key - 1] = arguments[_key]; _classCallCheck(this, E); }; diff --git a/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersMethodES6/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersMethodES6/input.ts/es5.1.normal/output.js index 56bff1b572b2d..bfe20eae0684f 100644 --- a/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersMethodES6/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersMethodES6/input.ts/es5.1.normal/output.js @@ -20,21 +20,21 @@ function _createClass(Constructor, protoProps, staticProps) { var C = // @target:es6 /*#__PURE__*/ function() { "use strict"; - function C(t, z, x, param) { - var y = param === void 0 ? "hello" : param; + function C(t, z, x) { + var y = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "hello"; _classCallCheck(this, C); } _createClass(C, [ { key: "foo", - value: function foo(x, param) { - var t = param === void 0 ? false : param; + value: function foo(x) { + var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false; } }, { key: "foo1", - value: function foo1(x, param) { - var t = param === void 0 ? false : param; + value: function foo1(x) { + var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false; for(var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){ rest[_key - 2] = arguments[_key]; } @@ -42,14 +42,14 @@ var C = // @target:es6 }, { key: "bar", - value: function bar(param) { - var t = param === void 0 ? false : param; + value: function bar() { + var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false; } }, { key: "boo", - value: function boo(param) { - var t = param === void 0 ? false : param; + value: function boo() { + var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false; for(var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){ rest[_key - 1] = arguments[_key]; } @@ -58,14 +58,14 @@ var C = // @target:es6 ]); return C; }(); -var D = function D(param) { +var D = function D() { "use strict"; - var y = param === void 0 ? "hello" : param; + var y = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "hello"; _classCallCheck(this, D); }; -var E = function E(param) { +var E = function E() { "use strict"; - var y = param === void 0 ? "hello" : param; + var y = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "hello"; for(var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){ rest[_key - 1] = arguments[_key]; } diff --git a/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersMethodES6/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersMethodES6/input.ts/es5.2.minified/output.js index 9273f9a6e8a7d..ebdd5a7978b94 100644 --- a/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersMethodES6/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/es6/defaultParameters/emitDefaultParametersMethodES6/input.ts/es5.2.minified/output.js @@ -10,38 +10,43 @@ function _defineProperties(target, props) { var C = function() { "use strict"; var Constructor, protoProps, staticProps; - function C(t, z, x, param) { - _classCallCheck(this, C); + function C(t, z, x) { + arguments.length > 3 && void 0 !== arguments[3] && arguments[3], _classCallCheck(this, C); } return Constructor = C, protoProps = [ { key: "foo", - value: function(x, param) { + value: function(x) { + arguments.length > 1 && void 0 !== arguments[1] && arguments[1]; } }, { key: "foo1", - value: function(x, param) { + value: function(x) { + arguments.length > 1 && void 0 !== arguments[1] && arguments[1]; for(var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++)rest[_key - 2] = arguments[_key]; } }, { key: "bar", - value: function(param) { + value: function() { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0]; } }, { key: "boo", - value: function(param) { + value: function() { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0]; for(var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++)rest[_key - 1] = arguments[_key]; } } ], _defineProperties(Constructor.prototype, protoProps), staticProps && _defineProperties(Constructor, staticProps), C; -}(), D = function(param) { +}(), D = function() { "use strict"; - _classCallCheck(this, D); -}, E = function(param) { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0], _classCallCheck(this, D); +}, E = function() { "use strict"; + arguments.length > 0 && void 0 !== arguments[0] && arguments[0]; for(var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++)rest[_key - 1] = arguments[_key]; _classCallCheck(this, E); }; diff --git a/crates/swc/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration1ES5/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration1ES5/input.ts/es5.1.normal/output.js index de3288deb76c8..f40c714acdeb2 100644 --- a/crates/swc/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration1ES5/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration1ES5/input.ts/es5.1.normal/output.js @@ -85,37 +85,37 @@ a1([ // If the declaration includes an initializer expression (which is permitted only // when the parameter list occurs in conjunction with a function body), // the parameter type is the widened form (section 3.11) of the type of the initializer expression. -function b1(param) { - var z = param === void 0 ? [ +function b1() { + var z = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [ undefined, null - ] : param; + ]; } -function b2(param, param1) { - var z = param === void 0 ? null : param, o = param1 === void 0 ? { +function b2() { + var z = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : null, o = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : { x: 0, y: undefined - } : param1; + }; } -function b3(param) { - var ref = param === void 0 ? { +function b3() { + var ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { z: { x: "hi", y: { j: 1 } } - } : param, _z = ref.z, x = _z.x, j = _z.y.j; + }, _z = ref.z, x = _z.x, j = _z.y.j; } -function b6(param) { - var ref = _slicedToArray(param === void 0 ? [ +function b6() { + var ref = _slicedToArray(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [ undefined, null, undefined - ] : param, 3), a = ref[0], z = ref[1], y = ref[2]; + ], 3), a = ref[0], z = ref[1], y = ref[2]; } -function b7(param) { - var ref = _slicedToArray(param === void 0 ? [ +function b7() { + var ref = _slicedToArray(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [ [ undefined ], @@ -126,7 +126,7 @@ function b7(param) { undefined ] ] - ] : param, 3), ref2 = _slicedToArray(ref[0], 1), a = ref2[0], b = ref[1], ref3 = _slicedToArray(ref[2], 1), ref4 = _slicedToArray(ref3[0], 2), c = ref4[0], d = ref4[1]; + ], 3), ref2 = _slicedToArray(ref[0], 1), a = ref2[0], b = ref[1], ref3 = _slicedToArray(ref[2], 1), ref4 = _slicedToArray(ref3[0], 2), c = ref4[0], d = ref4[1]; } b1([ 1, @@ -167,18 +167,18 @@ Foo1; function c0(param) { var _z = param.z, x = _z.x, j = _z.y.j; } -function c1(param) { - var z = (param === void 0 ? { +function c1() { + var z = (arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { z: 10 - } : param).z; + }).z; } function c2(param) { var _z = param.z, z = _z === void 0 ? 10 : _z; } -function c3(param) { - var b = (param === void 0 ? { +function c3() { + var b = (arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { b: "hello" - } : param).b; + }).b; } function c5(param) { var _param = _slicedToArray(param, 3), a = _param[0], b = _param[1], ref = _slicedToArray(_param[2], 1), ref5 = _slicedToArray(ref[0], 1), c = ref5[0]; @@ -239,8 +239,8 @@ c5([ // or by including an initializer. function d0(x) { } -function d0(param) { - var x = param === void 0 ? 10 : param; +function d0() { + var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 10; } var C2 = /*#__PURE__*/ function() { "use strict"; @@ -294,11 +294,11 @@ var C3 = /*#__PURE__*/ function() { ]); return C3; }(); -function d5(param) { - var ref = param === void 0 ? { +function d5() { + var ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { x: 1, y: 2 - } : param, x = ref.x, y = ref.y; + }, x = ref.x, y = ref.y; } d5(); // Parameter is optional as its declaration included an initializer // Destructuring parameter declarations do not permit type annotations on the individual binding patterns, diff --git a/crates/swc/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration1ES5/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration1ES5/input.ts/es5.2.minified/output.js index d3ee9b4c0dc59..0d997333ddd34 100644 --- a/crates/swc/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration1ES5/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration1ES5/input.ts/es5.2.minified/output.js @@ -35,16 +35,17 @@ function a1(param) { var _param = _slicedToArray(param, 3), a = _param[0], b = _param[1], ref = _slicedToArray(_param[2], 1), ref1 = _slicedToArray(ref[0], 1); ref1[0]; } -function b2(param, param1) { +function b2() { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0], arguments.length > 1 && void 0 !== arguments[1] && arguments[1]; } function c0(param) { var _z = param.z; _z.x, _z.y.j; } -function c1(param) { - (void 0 === param ? { +function c1() { + (arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : { z: 10 - } : param).z; + }).z; } function c2(param) { param.z; @@ -70,25 +71,31 @@ a1([ ] ], 3 +]), (function() { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0]; +})([ + 1, + 2, + 3 ]), b2("string", { x: 200, y: "string" }), b2("string", { x: 200, y: !0 -}), (function(param) { - var ref = _slicedToArray(void 0 === param ? [ +}), (function() { + var ref = _slicedToArray(arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : [ void 0, null, void 0 - ] : param, 3); + ], 3); ref[0], ref[1], ref[2]; })([ "string", 1, 2 -]), (function(param) { - var ref = _slicedToArray(void 0 === param ? [ +]), (function() { + var ref = _slicedToArray(arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : [ [ void 0 ], @@ -99,7 +106,7 @@ a1([ void 0 ] ] - ] : param, 3), a = _slicedToArray(ref[0], 1)[0], b = ref[1], ref3 = _slicedToArray(ref[2], 1), ref4 = _slicedToArray(ref3[0], 2); + ], 3), a = _slicedToArray(ref[0], 1)[0], b = ref[1], ref3 = _slicedToArray(ref[2], 1), ref4 = _slicedToArray(ref3[0], 2); ref4[0], ref4[1]; })([ [ @@ -132,6 +139,12 @@ a1([ }), c2({ }), c2({ z: 1 +}), (function() { + (arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : { + b: "hello" + }).b; +})({ + b: 1 }), c5([ 1, 2, @@ -203,10 +216,10 @@ var Foo, Foo1, C2 = function() { } ]), C3; }(); -!function(param) { - var ref = void 0 === param ? { +!function() { + var ref = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : { x: 1, y: 2 - } : param; + }; ref.x, ref.y; }(); diff --git a/crates/swc/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration1ES5iterable/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration1ES5iterable/input.ts/es5.1.normal/output.js index 9e33296cc843d..0e8e94bf76e29 100644 --- a/crates/swc/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration1ES5iterable/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration1ES5iterable/input.ts/es5.1.normal/output.js @@ -86,37 +86,37 @@ a1([ // If the declaration includes an initializer expression (which is permitted only // when the parameter list occurs in conjunction with a function body), // the parameter type is the widened form (section 3.11) of the type of the initializer expression. -function b1(param) { - var z = param === void 0 ? [ +function b1() { + var z = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [ undefined, null - ] : param; + ]; } -function b2(param, param1) { - var z = param === void 0 ? null : param, o = param1 === void 0 ? { +function b2() { + var z = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : null, o = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : { x: 0, y: undefined - } : param1; + }; } -function b3(param) { - var ref = param === void 0 ? { +function b3() { + var ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { z: { x: "hi", y: { j: 1 } } - } : param, _z = ref.z, x = _z.x, j = _z.y.j; + }, _z = ref.z, x = _z.x, j = _z.y.j; } -function b6(param) { - var ref = _slicedToArray(param === void 0 ? [ +function b6() { + var ref = _slicedToArray(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [ undefined, null, undefined - ] : param, 3), a = ref[0], z = ref[1], y = ref[2]; + ], 3), a = ref[0], z = ref[1], y = ref[2]; } -function b7(param) { - var ref = _slicedToArray(param === void 0 ? [ +function b7() { + var ref = _slicedToArray(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [ [ undefined ], @@ -127,7 +127,7 @@ function b7(param) { undefined ] ] - ] : param, 3), ref2 = _slicedToArray(ref[0], 1), a = ref2[0], b = ref[1], ref3 = _slicedToArray(ref[2], 1), ref4 = _slicedToArray(ref3[0], 2), c = ref4[0], d = ref4[1]; + ], 3), ref2 = _slicedToArray(ref[0], 1), a = ref2[0], b = ref[1], ref3 = _slicedToArray(ref[2], 1), ref4 = _slicedToArray(ref3[0], 2), c = ref4[0], d = ref4[1]; } b1([ 1, @@ -168,18 +168,18 @@ Foo1; function c0(param) { var _z = param.z, x = _z.x, j = _z.y.j; } -function c1(param) { - var z = (param === void 0 ? { +function c1() { + var z = (arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { z: 10 - } : param).z; + }).z; } function c2(param) { var _z = param.z, z = _z === void 0 ? 10 : _z; } -function c3(param) { - var b = (param === void 0 ? { +function c3() { + var b = (arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { b: "hello" - } : param).b; + }).b; } function c5(param) { var _param = _slicedToArray(param, 3), a = _param[0], b = _param[1], ref = _slicedToArray(_param[2], 1), ref5 = _slicedToArray(ref[0], 1), c = ref5[0]; @@ -240,8 +240,8 @@ c5([ // or by including an initializer. function d0(x) { } -function d0(param) { - var x = param === void 0 ? 10 : param; +function d0() { + var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 10; } var C2 = /*#__PURE__*/ function() { "use strict"; @@ -295,11 +295,11 @@ var C3 = /*#__PURE__*/ function() { ]); return C3; }(); -function d5(param) { - var ref = param === void 0 ? { +function d5() { + var ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { x: 1, y: 2 - } : param, x = ref.x, y = ref.y; + }, x = ref.x, y = ref.y; } d5(); // Parameter is optional as its declaration included an initializer // Destructuring parameter declarations do not permit type annotations on the individual binding patterns, diff --git a/crates/swc/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration1ES5iterable/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration1ES5iterable/input.ts/es5.2.minified/output.js index d3ee9b4c0dc59..0d997333ddd34 100644 --- a/crates/swc/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration1ES5iterable/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration1ES5iterable/input.ts/es5.2.minified/output.js @@ -35,16 +35,17 @@ function a1(param) { var _param = _slicedToArray(param, 3), a = _param[0], b = _param[1], ref = _slicedToArray(_param[2], 1), ref1 = _slicedToArray(ref[0], 1); ref1[0]; } -function b2(param, param1) { +function b2() { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0], arguments.length > 1 && void 0 !== arguments[1] && arguments[1]; } function c0(param) { var _z = param.z; _z.x, _z.y.j; } -function c1(param) { - (void 0 === param ? { +function c1() { + (arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : { z: 10 - } : param).z; + }).z; } function c2(param) { param.z; @@ -70,25 +71,31 @@ a1([ ] ], 3 +]), (function() { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0]; +})([ + 1, + 2, + 3 ]), b2("string", { x: 200, y: "string" }), b2("string", { x: 200, y: !0 -}), (function(param) { - var ref = _slicedToArray(void 0 === param ? [ +}), (function() { + var ref = _slicedToArray(arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : [ void 0, null, void 0 - ] : param, 3); + ], 3); ref[0], ref[1], ref[2]; })([ "string", 1, 2 -]), (function(param) { - var ref = _slicedToArray(void 0 === param ? [ +]), (function() { + var ref = _slicedToArray(arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : [ [ void 0 ], @@ -99,7 +106,7 @@ a1([ void 0 ] ] - ] : param, 3), a = _slicedToArray(ref[0], 1)[0], b = ref[1], ref3 = _slicedToArray(ref[2], 1), ref4 = _slicedToArray(ref3[0], 2); + ], 3), a = _slicedToArray(ref[0], 1)[0], b = ref[1], ref3 = _slicedToArray(ref[2], 1), ref4 = _slicedToArray(ref3[0], 2); ref4[0], ref4[1]; })([ [ @@ -132,6 +139,12 @@ a1([ }), c2({ }), c2({ z: 1 +}), (function() { + (arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : { + b: "hello" + }).b; +})({ + b: 1 }), c5([ 1, 2, @@ -203,10 +216,10 @@ var Foo, Foo1, C2 = function() { } ]), C3; }(); -!function(param) { - var ref = void 0 === param ? { +!function() { + var ref = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : { x: 1, y: 2 - } : param; + }; ref.x, ref.y; }(); diff --git a/crates/swc/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration1ES6/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration1ES6/input.ts/es5.1.normal/output.js index 628a812c3f32d..19eb1842b4399 100644 --- a/crates/swc/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration1ES6/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration1ES6/input.ts/es5.1.normal/output.js @@ -87,37 +87,37 @@ a1([ // If the declaration includes an initializer expression (which is permitted only // when the parameter list occurs in conjunction with a function body), // the parameter type is the widened form (section 3.11) of the type of the initializer expression. -function b1(param) { - var z = param === void 0 ? [ +function b1() { + var z = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [ undefined, null - ] : param; + ]; } -function b2(param, param1) { - var z = param === void 0 ? null : param, o = param1 === void 0 ? { +function b2() { + var z = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : null, o = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : { x: 0, y: undefined - } : param1; + }; } -function b3(param) { - var ref = param === void 0 ? { +function b3() { + var ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { z: { x: "hi", y: { j: 1 } } - } : param, _z = ref.z, x = _z.x, j = _z.y.j; + }, _z = ref.z, x = _z.x, j = _z.y.j; } -function b6(param) { - var ref = _slicedToArray(param === void 0 ? [ +function b6() { + var ref = _slicedToArray(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [ undefined, null, undefined - ] : param, 3), a = ref[0], z = ref[1], y = ref[2]; + ], 3), a = ref[0], z = ref[1], y = ref[2]; } -function b7(param) { - var ref = _slicedToArray(param === void 0 ? [ +function b7() { + var ref = _slicedToArray(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [ [ undefined ], @@ -128,7 +128,7 @@ function b7(param) { undefined ] ] - ] : param, 3), ref2 = _slicedToArray(ref[0], 1), a = ref2[0], b = ref[1], ref3 = _slicedToArray(ref[2], 1), ref4 = _slicedToArray(ref3[0], 2), c = ref4[0], d = ref4[1]; + ], 3), ref2 = _slicedToArray(ref[0], 1), a = ref2[0], b = ref[1], ref3 = _slicedToArray(ref[2], 1), ref4 = _slicedToArray(ref3[0], 2), c = ref4[0], d = ref4[1]; } b1([ 1, @@ -152,18 +152,18 @@ Foo1; function c0(param) { var _z = param.z, x = _z.x, j = _z.y.j; } -function c1(param) { - var z = (param === void 0 ? { +function c1() { + var z = (arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { z: 10 - } : param).z; + }).z; } function c2(param) { var _z = param.z, z = _z === void 0 ? 10 : _z; } -function c3(param) { - var b = (param === void 0 ? { +function c3() { + var b = (arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { b: "hello" - } : param).b; + }).b; } function c5(param) { var _param = _slicedToArray(param, 3), a = _param[0], b = _param[1], ref = _slicedToArray(_param[2], 1), ref5 = _slicedToArray(ref[0], 1), c = ref5[0]; @@ -272,11 +272,11 @@ var C3 = /*#__PURE__*/ function() { ]); return C3; }(); -function d5(param) { - var ref = param === void 0 ? { +function d5() { + var ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { x: 1, y: 2 - } : param, x = ref.x, y = ref.y; + }, x = ref.x, y = ref.y; } d5(); // Parameter is optional as its declaration included an initializer // Destructuring parameter declarations do not permit type annotations on the individual binding patterns, diff --git a/crates/swc/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration1ES6/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration1ES6/input.ts/es5.2.minified/output.js index ea374b32171c9..f99f407b1e69e 100644 --- a/crates/swc/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration1ES6/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration1ES6/input.ts/es5.2.minified/output.js @@ -35,16 +35,17 @@ function a1(param) { var _param = _slicedToArray(param, 3), a = _param[0], b = _param[1], ref = _slicedToArray(_param[2], 1), ref1 = _slicedToArray(ref[0], 1); ref1[0]; } -function b2(param, param1) { +function b2() { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0], arguments.length > 1 && void 0 !== arguments[1] && arguments[1]; } function c0(param) { var _z = param.z; _z.x, _z.y.j; } -function c1(param) { - (void 0 === param ? { +function c1() { + (arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : { z: 10 - } : param).z; + }).z; } function c2(param) { param.z; @@ -70,6 +71,12 @@ a1([ ] ], 3 +]), (function() { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0]; +})([ + 1, + 2, + 3 ]), b2("string", { x: 200, y: "string" @@ -96,6 +103,12 @@ a1([ }), c2({ }), c2({ z: 1 +}), (function() { + (arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : { + b: "hello" + }).b; +})({ + b: 1 }), c5([ 1, 2, @@ -167,10 +180,10 @@ var Foo, Foo1, C2 = function() { } ]), C3; }(); -!function(param) { - var ref = void 0 === param ? { +!function() { + var ref = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : { x: 1, y: 2 - } : param; + }; ref.x, ref.y; }(); diff --git a/crates/swc/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration5/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration5/input.ts/es5.1.normal/output.js index ca1b61252ae3f..536dfbdad3332 100644 --- a/crates/swc/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration5/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration5/input.ts/es5.1.normal/output.js @@ -97,10 +97,10 @@ var SubD = /*#__PURE__*/ function(D) { } return SubD; }(D); -function d0(param) { - var x = (param === void 0 ? { +function d0() { + var x = (arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { x: new Class() - } : param).x; + }).x; } function d1(param) { var x = param.x; @@ -111,10 +111,10 @@ function d2(param) { function d3(param) { var y = param.y; } -function d4(param) { - var y = (param === void 0 ? { +function d4() { + var y = (arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { y: new D() - } : param).y; + }).y; } var obj1 = new Class(); d0({ diff --git a/crates/swc/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration5/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration5/input.ts/es5.2.minified/output.js index 884a6f75813ec..6c08986b50597 100644 --- a/crates/swc/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration5/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration5/input.ts/es5.2.minified/output.js @@ -68,10 +68,10 @@ var Class1 = function() { } return SubD; }(D1); -function d0(param) { - (void 0 === param ? { +function d0() { + (arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : { x: new Class1() - } : param).x; + }).x; } function d1(param) { param.x; diff --git a/crates/swc/tests/tsc-references/es6/destructuring/destructuringWithLiteralInitializers/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/es6/destructuring/destructuringWithLiteralInitializers/input.ts/es5.1.normal/output.js index 1a373241ae9ba..38b647212e5f9 100644 --- a/crates/swc/tests/tsc-references/es6/destructuring/destructuringWithLiteralInitializers/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/es6/destructuring/destructuringWithLiteralInitializers/input.ts/es5.1.normal/output.js @@ -65,11 +65,11 @@ f3({ y: 1 }); // (arg?: { x: number, y: number }) => void -function f4(param) { - var ref = param === void 0 ? { +function f4() { + var ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { x: 0, y: 0 - } : param, x = ref.x, y = ref.y; + }, x = ref.x, y = ref.y; } f4(); f4({ @@ -77,10 +77,10 @@ f4({ y: 1 }); // (arg?: { x: number, y?: number }) => void -function f5(param) { - var ref = param === void 0 ? { +function f5() { + var ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { x: 0 - } : param, x = ref.x, _y = ref.y, y = _y === void 0 ? 0 : _y; + }, x = ref.x, _y = ref.y, y = _y === void 0 ? 0 : _y; } f5(); f5({ @@ -91,9 +91,9 @@ f5({ y: 1 }); // (arg?: { x?: number, y?: number }) => void -function f6(param) { - var ref = param === void 0 ? { - } : param, _x = ref.x, x = _x === void 0 ? 0 : _x, _y = ref.y, y = _y === void 0 ? 0 : _y; +function f6() { + var ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { + }, _x = ref.x, x = _x === void 0 ? 0 : _x, _y = ref.y, y = _y === void 0 ? 0 : _y; } f6(); f6({ @@ -109,11 +109,11 @@ f6({ y: 1 }); // (arg?: { a: { x?: number, y?: number } }) => void -function f7(param) { - var ref = param === void 0 ? { +function f7() { + var ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { a: { } - } : param, _a = ref.a, _x = _a.x, x = _x === void 0 ? 0 : _x, _y = _a.y, y = _y === void 0 ? 0 : _y; + }, _a = ref.a, _x = _a.x, x = _x === void 0 ? 0 : _x, _y = _a.y, y = _y === void 0 ? 0 : _y; } f7(); f7({ @@ -153,11 +153,11 @@ g2([ 1 ]); // (arg?: [number, number]) => void -function g3(param) { - var ref = _slicedToArray(param === void 0 ? [ +function g3() { + var ref = _slicedToArray(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [ 0, 0 - ] : param, 2), x = ref[0], y = ref[1]; + ], 2), x = ref[0], y = ref[1]; } g3(); g3([ @@ -165,10 +165,10 @@ g3([ 1 ]); // (arg?: [number, number]) => void -function g4(param) { - var ref = _slicedToArray(param === void 0 ? [ +function g4() { + var ref = _slicedToArray(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [ 0 - ] : param, 2), x = ref[0], tmp = ref[1], y = tmp === void 0 ? 0 : tmp; + ], 2), x = ref[0], tmp = ref[1], y = tmp === void 0 ? 0 : tmp; } g4(); g4([ @@ -176,8 +176,8 @@ g4([ 1 ]); // (arg?: [number, number]) => void -function g5(param) { - var ref = _slicedToArray(param === void 0 ? [] : param, 2), tmp = ref[0], x = tmp === void 0 ? 0 : tmp, tmp2 = ref[1], y = tmp2 === void 0 ? 0 : tmp2; +function g5() { + var ref = _slicedToArray(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], 2), tmp = ref[0], x = tmp === void 0 ? 0 : tmp, tmp2 = ref[1], y = tmp2 === void 0 ? 0 : tmp2; } g5(); g5([ diff --git a/crates/swc/tests/tsc-references/es6/destructuring/destructuringWithLiteralInitializers/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/es6/destructuring/destructuringWithLiteralInitializers/input.ts/es5.2.minified/output.js index 4c481c12f8221..18dd4e7ab619c 100644 --- a/crates/swc/tests/tsc-references/es6/destructuring/destructuringWithLiteralInitializers/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/es6/destructuring/destructuringWithLiteralInitializers/input.ts/es5.2.minified/output.js @@ -27,46 +27,46 @@ function f2(param) { function f3(param) { param.x, param.y; } -function f4(param) { - var ref = void 0 === param ? { +function f4() { + var ref = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : { x: 0, y: 0 - } : param; + }; ref.x, ref.y; } -function f5(param) { - var ref = void 0 === param ? { +function f5() { + var ref = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : { x: 0 - } : param; + }; ref.x, ref.y; } -function f6(param) { - var ref = void 0 === param ? { - } : param; +function f6() { + var ref = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : { + }; ref.x, ref.y; } -function f7(param) { - var _a = (void 0 === param ? { +function f7() { + var ref = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : { a: { } - } : param).a; + }, _a = ref.a; _a.x, _a.y; } -function g3(param) { - var ref = _slicedToArray(void 0 === param ? [ +function g3() { + var ref = _slicedToArray(arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : [ 0, 0 - ] : param, 2); + ], 2); ref[0], ref[1]; } -function g4(param) { - var ref = _slicedToArray(void 0 === param ? [ +function g4() { + var ref = _slicedToArray(arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : [ 0 - ] : param, 2); + ], 2); ref[0], ref[1]; } -function g5(param) { - var ref = _slicedToArray(void 0 === param ? [] : param, 2); +function g5() { + var ref = _slicedToArray(arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : [], 2); ref[0], ref[1]; } (param1 = { diff --git a/crates/swc/tests/tsc-references/es6/destructuring/destructuringWithLiteralInitializers2/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/es6/destructuring/destructuringWithLiteralInitializers2/input.ts/es5.1.normal/output.js index 7c450f5ad8339..3a967e9a4a4c4 100644 --- a/crates/swc/tests/tsc-references/es6/destructuring/destructuringWithLiteralInitializers2/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/es6/destructuring/destructuringWithLiteralInitializers2/input.ts/es5.1.normal/output.js @@ -33,85 +33,85 @@ function _slicedToArray(arr, i) { function f00(param) { var _param = _slicedToArray(param, 2), x = _param[0], y = _param[1]; } -function f01(param) { - var ref = _slicedToArray(param === void 0 ? [] : param, 2), x = ref[0], y = ref[1]; +function f01() { + var ref = _slicedToArray(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], 2), x = ref[0], y = ref[1]; } -function f02(param) { - var ref = _slicedToArray(param === void 0 ? [ +function f02() { + var ref = _slicedToArray(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [ 1 - ] : param, 2), x = ref[0], y = ref[1]; + ], 2), x = ref[0], y = ref[1]; } -function f03(param) { - var ref = _slicedToArray(param === void 0 ? [ +function f03() { + var ref = _slicedToArray(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [ 1, 'foo' - ] : param, 2), x = ref[0], y = ref[1]; + ], 2), x = ref[0], y = ref[1]; } function f10(param) { var _param = _slicedToArray(param, 2), tmp = _param[0], x = tmp === void 0 ? 0 : tmp, y = _param[1]; } -function f11(param) { - var ref = _slicedToArray(param === void 0 ? [] : param, 2), tmp = ref[0], x = tmp === void 0 ? 0 : tmp, y = ref[1]; +function f11() { + var ref = _slicedToArray(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], 2), tmp = ref[0], x = tmp === void 0 ? 0 : tmp, y = ref[1]; } -function f12(param) { - var ref = _slicedToArray(param === void 0 ? [ +function f12() { + var ref = _slicedToArray(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [ 1 - ] : param, 2), tmp = ref[0], x = tmp === void 0 ? 0 : tmp, y = ref[1]; + ], 2), tmp = ref[0], x = tmp === void 0 ? 0 : tmp, y = ref[1]; } -function f13(param) { - var ref = _slicedToArray(param === void 0 ? [ +function f13() { + var ref = _slicedToArray(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [ 1, 'foo' - ] : param, 2), tmp = ref[0], x = tmp === void 0 ? 0 : tmp, y = ref[1]; + ], 2), tmp = ref[0], x = tmp === void 0 ? 0 : tmp, y = ref[1]; } function f20(param) { var _param = _slicedToArray(param, 2), tmp = _param[0], x = tmp === void 0 ? 0 : tmp, tmp1 = _param[1], y = tmp1 === void 0 ? 'bar' : tmp1; } -function f21(param) { - var ref = _slicedToArray(param === void 0 ? [] : param, 2), tmp = ref[0], x = tmp === void 0 ? 0 : tmp, tmp2 = ref[1], y = tmp2 === void 0 ? 'bar' : tmp2; +function f21() { + var ref = _slicedToArray(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], 2), tmp = ref[0], x = tmp === void 0 ? 0 : tmp, tmp2 = ref[1], y = tmp2 === void 0 ? 'bar' : tmp2; } -function f22(param) { - var ref = _slicedToArray(param === void 0 ? [ +function f22() { + var ref = _slicedToArray(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [ 1 - ] : param, 2), tmp = ref[0], x = tmp === void 0 ? 0 : tmp, tmp3 = ref[1], y = tmp3 === void 0 ? 'bar' : tmp3; + ], 2), tmp = ref[0], x = tmp === void 0 ? 0 : tmp, tmp3 = ref[1], y = tmp3 === void 0 ? 'bar' : tmp3; } -function f23(param) { - var ref = _slicedToArray(param === void 0 ? [ +function f23() { + var ref = _slicedToArray(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [ 1, 'foo' - ] : param, 2), tmp = ref[0], x = tmp === void 0 ? 0 : tmp, tmp4 = ref[1], y = tmp4 === void 0 ? 'bar' : tmp4; + ], 2), tmp = ref[0], x = tmp === void 0 ? 0 : tmp, tmp4 = ref[1], y = tmp4 === void 0 ? 'bar' : tmp4; } function f30(param) { var _param = _slicedToArray(param, 2), tmp = _param[0], x = tmp === void 0 ? 0 : tmp, tmp5 = _param[1], y = tmp5 === void 0 ? 'bar' : tmp5; } -function f31(param) { - var ref = _slicedToArray(param === void 0 ? [] : param, 2), tmp = ref[0], x = tmp === void 0 ? 0 : tmp, tmp6 = ref[1], y = tmp6 === void 0 ? 'bar' : tmp6; +function f31() { + var ref = _slicedToArray(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], 2), tmp = ref[0], x = tmp === void 0 ? 0 : tmp, tmp6 = ref[1], y = tmp6 === void 0 ? 'bar' : tmp6; } -function f32(param) { - var ref = _slicedToArray(param === void 0 ? [ +function f32() { + var ref = _slicedToArray(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [ nx - ] : param, 2), tmp = ref[0], x = tmp === void 0 ? 0 : tmp, tmp7 = ref[1], y = tmp7 === void 0 ? 'bar' : tmp7; + ], 2), tmp = ref[0], x = tmp === void 0 ? 0 : tmp, tmp7 = ref[1], y = tmp7 === void 0 ? 'bar' : tmp7; } -function f33(param) { - var ref = _slicedToArray(param === void 0 ? [ +function f33() { + var ref = _slicedToArray(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [ nx, sx - ] : param, 2), tmp = ref[0], x = tmp === void 0 ? 0 : tmp, tmp8 = ref[1], y = tmp8 === void 0 ? 'bar' : tmp8; + ], 2), tmp = ref[0], x = tmp === void 0 ? 0 : tmp, tmp8 = ref[1], y = tmp8 === void 0 ? 'bar' : tmp8; } function f40(param) { var _param = _slicedToArray(param, 2), tmp = _param[0], x = tmp === void 0 ? 0 : tmp, tmp9 = _param[1], y = tmp9 === void 0 ? 'bar' : tmp9; } -function f41(param) { - var ref = _slicedToArray(param === void 0 ? [] : param, 2), tmp = ref[0], x = tmp === void 0 ? 0 : tmp, tmp10 = ref[1], y = tmp10 === void 0 ? 'bar' : tmp10; +function f41() { + var ref = _slicedToArray(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], 2), tmp = ref[0], x = tmp === void 0 ? 0 : tmp, tmp10 = ref[1], y = tmp10 === void 0 ? 'bar' : tmp10; } -function f42(param) { - var ref = _slicedToArray(param === void 0 ? [ +function f42() { + var ref = _slicedToArray(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [ sx - ] : param, 2), tmp = ref[0], x = tmp === void 0 ? 0 : tmp, tmp11 = ref[1], y = tmp11 === void 0 ? 'bar' : tmp11; + ], 2), tmp = ref[0], x = tmp === void 0 ? 0 : tmp, tmp11 = ref[1], y = tmp11 === void 0 ? 'bar' : tmp11; } -function f43(param) { - var ref = _slicedToArray(param === void 0 ? [ +function f43() { + var ref = _slicedToArray(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [ sx, nx - ] : param, 2), tmp = ref[0], x = tmp === void 0 ? 0 : tmp, tmp12 = ref[1], y = tmp12 === void 0 ? 'bar' : tmp12; + ], 2), tmp = ref[0], x = tmp === void 0 ? 0 : tmp, tmp12 = ref[1], y = tmp12 === void 0 ? 'bar' : tmp12; } diff --git a/crates/swc/tests/tsc-references/es6/destructuring/emptyArrayBindingPatternParameter04/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/es6/destructuring/emptyArrayBindingPatternParameter04/input.ts/es5.1.normal/output.js index 32f57ee764748..71960283a87c7 100644 --- a/crates/swc/tests/tsc-references/es6/destructuring/emptyArrayBindingPatternParameter04/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/es6/destructuring/emptyArrayBindingPatternParameter04/input.ts/es5.1.normal/output.js @@ -30,12 +30,12 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } // @declaration: true -function f(param) { - var ref = _slicedToArray(param === void 0 ? [ +function f() { + var ref = _slicedToArray(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [ 1, 2, 3, 4 - ] : param, 0); + ], 0); var x, y, z; } diff --git a/crates/swc/tests/tsc-references/es6/destructuring/emptyObjectBindingPatternParameter04/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/es6/destructuring/emptyObjectBindingPatternParameter04/input.ts/es5.1.normal/output.js index 25e04762beeb4..242215b0e1fe2 100644 --- a/crates/swc/tests/tsc-references/es6/destructuring/emptyObjectBindingPatternParameter04/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/es6/destructuring/emptyObjectBindingPatternParameter04/input.ts/es5.1.normal/output.js @@ -2,11 +2,11 @@ function _throw(e) { throw e; } // @declaration: true -function f(param) { - var ref = param === void 0 ? { +function f() { + var ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { a: 1, b: "2", c: true - } : param, ref = ref !== null ? ref : _throw(new TypeError("Cannot destructure undefined")); + }, ref = ref !== null ? ref : _throw(new TypeError("Cannot destructure undefined")); var x, y, z; } diff --git a/crates/swc/tests/tsc-references/es6/destructuring/emptyVariableDeclarationBindingPatterns01_ES5/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/es6/destructuring/emptyVariableDeclarationBindingPatterns01_ES5/input.ts/es5.1.normal/output.js index 00eafb63508c8..69cf0f3b1ccd4 100644 --- a/crates/swc/tests/tsc-references/es6/destructuring/emptyVariableDeclarationBindingPatterns01_ES5/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/es6/destructuring/emptyVariableDeclarationBindingPatterns01_ES5/input.ts/es5.1.normal/output.js @@ -34,10 +34,10 @@ function _throw(e) { } // @target: es5 (function() { - var f = function f(param5, param1, param2) { - var ref9 = param5 === void 0 ? a : param5, ref9 = ref9 !== null ? ref9 : _throw(new TypeError("Cannot destructure undefined")), ref2 = _slicedToArray(param1 === void 0 ? a : param1, 0), ref3 = param2 === void 0 ? a : param2, tmp1 = ref3.p, ref4 = tmp1 === void 0 ? a : tmp1, ref4 = ref4 !== null ? ref4 : _throw(new TypeError("Cannot destructure undefined")); - return function(param, param3, param4) { - var ref = param === void 0 ? a : param, ref = ref !== null ? ref : _throw(new TypeError("Cannot destructure undefined")), ref6 = _slicedToArray(param3 === void 0 ? a : param3, 0), ref7 = param4 === void 0 ? a : param4, tmp = ref7.p, ref8 = tmp === void 0 ? a : tmp, ref8 = ref8 !== null ? ref8 : _throw(new TypeError("Cannot destructure undefined")); + var f = function f() { + var ref9 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : a, ref9 = ref9 !== null ? ref9 : _throw(new TypeError("Cannot destructure undefined")), ref2 = _slicedToArray(arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : a, 0), ref3 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : a, tmp1 = ref3.p, ref4 = tmp1 === void 0 ? a : tmp1, ref4 = ref4 !== null ? ref4 : _throw(new TypeError("Cannot destructure undefined")); + return function() { + var ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : a, ref = ref !== null ? ref : _throw(new TypeError("Cannot destructure undefined")), ref6 = _slicedToArray(arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : a, 0), ref7 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : a, tmp = ref7.p, ref8 = tmp === void 0 ? a : tmp, ref8 = ref8 !== null ? ref8 : _throw(new TypeError("Cannot destructure undefined")); return a; }; }; diff --git a/crates/swc/tests/tsc-references/es6/destructuring/emptyVariableDeclarationBindingPatterns01_ES5iterable/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/es6/destructuring/emptyVariableDeclarationBindingPatterns01_ES5iterable/input.ts/es5.1.normal/output.js index 53e811c6451d6..cf94d295fbd9d 100644 --- a/crates/swc/tests/tsc-references/es6/destructuring/emptyVariableDeclarationBindingPatterns01_ES5iterable/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/es6/destructuring/emptyVariableDeclarationBindingPatterns01_ES5iterable/input.ts/es5.1.normal/output.js @@ -35,10 +35,10 @@ function _throw(e) { // @target: es5 // @downlevelIteration: true (function() { - var f = function f(param5, param1, param2) { - var ref9 = param5 === void 0 ? a : param5, ref9 = ref9 !== null ? ref9 : _throw(new TypeError("Cannot destructure undefined")), ref2 = _slicedToArray(param1 === void 0 ? a : param1, 0), ref3 = param2 === void 0 ? a : param2, tmp1 = ref3.p, ref4 = tmp1 === void 0 ? a : tmp1, ref4 = ref4 !== null ? ref4 : _throw(new TypeError("Cannot destructure undefined")); - return function(param, param3, param4) { - var ref = param === void 0 ? a : param, ref = ref !== null ? ref : _throw(new TypeError("Cannot destructure undefined")), ref6 = _slicedToArray(param3 === void 0 ? a : param3, 0), ref7 = param4 === void 0 ? a : param4, tmp = ref7.p, ref8 = tmp === void 0 ? a : tmp, ref8 = ref8 !== null ? ref8 : _throw(new TypeError("Cannot destructure undefined")); + var f = function f() { + var ref9 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : a, ref9 = ref9 !== null ? ref9 : _throw(new TypeError("Cannot destructure undefined")), ref2 = _slicedToArray(arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : a, 0), ref3 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : a, tmp1 = ref3.p, ref4 = tmp1 === void 0 ? a : tmp1, ref4 = ref4 !== null ? ref4 : _throw(new TypeError("Cannot destructure undefined")); + return function() { + var ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : a, ref = ref !== null ? ref : _throw(new TypeError("Cannot destructure undefined")), ref6 = _slicedToArray(arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : a, 0), ref7 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : a, tmp = ref7.p, ref8 = tmp === void 0 ? a : tmp, ref8 = ref8 !== null ? ref8 : _throw(new TypeError("Cannot destructure undefined")); return a; }; }; diff --git a/crates/swc/tests/tsc-references/es6/destructuring/emptyVariableDeclarationBindingPatterns01_ES6/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/es6/destructuring/emptyVariableDeclarationBindingPatterns01_ES6/input.ts/es5.1.normal/output.js index 9e541fc78296a..4099089f2e0f7 100644 --- a/crates/swc/tests/tsc-references/es6/destructuring/emptyVariableDeclarationBindingPatterns01_ES6/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/es6/destructuring/emptyVariableDeclarationBindingPatterns01_ES6/input.ts/es5.1.normal/output.js @@ -34,10 +34,10 @@ function _throw(e) { } // @target: es6 (function() { - var f = function f(param5, param1, param2) { - var ref9 = param5 === void 0 ? a : param5, ref9 = ref9 !== null ? ref9 : _throw(new TypeError("Cannot destructure undefined")), ref2 = _slicedToArray(param1 === void 0 ? a : param1, 0), ref3 = param2 === void 0 ? a : param2, tmp1 = ref3.p, ref4 = tmp1 === void 0 ? a : tmp1, ref4 = ref4 !== null ? ref4 : _throw(new TypeError("Cannot destructure undefined")); - return function(param, param3, param4) { - var ref = param === void 0 ? a : param, ref = ref !== null ? ref : _throw(new TypeError("Cannot destructure undefined")), ref6 = _slicedToArray(param3 === void 0 ? a : param3, 0), ref7 = param4 === void 0 ? a : param4, tmp = ref7.p, ref8 = tmp === void 0 ? a : tmp, ref8 = ref8 !== null ? ref8 : _throw(new TypeError("Cannot destructure undefined")); + var f = function f() { + var ref9 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : a, ref9 = ref9 !== null ? ref9 : _throw(new TypeError("Cannot destructure undefined")), ref2 = _slicedToArray(arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : a, 0), ref3 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : a, tmp1 = ref3.p, ref4 = tmp1 === void 0 ? a : tmp1, ref4 = ref4 !== null ? ref4 : _throw(new TypeError("Cannot destructure undefined")); + return function() { + var ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : a, ref = ref !== null ? ref : _throw(new TypeError("Cannot destructure undefined")), ref6 = _slicedToArray(arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : a, 0), ref7 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : a, tmp = ref7.p, ref8 = tmp === void 0 ? a : tmp, ref8 = ref8 !== null ? ref8 : _throw(new TypeError("Cannot destructure undefined")); return a; }; }; diff --git a/crates/swc/tests/tsc-references/es6/destructuring/iterableArrayPattern11/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/es6/destructuring/iterableArrayPattern11/input.ts/es5.1.normal/output.js index 05bb7461df1d6..a3221e682ec5b 100644 --- a/crates/swc/tests/tsc-references/es6/destructuring/iterableArrayPattern11/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/es6/destructuring/iterableArrayPattern11/input.ts/es5.1.normal/output.js @@ -153,7 +153,7 @@ var FooIterator = /*#__PURE__*/ function() { ]); return FooIterator; }(); -function fun(param) { - var ref = _slicedToArray(param === void 0 ? new FooIterator : param, 2), a = ref[0], b = ref[1]; +function fun() { + var ref = _slicedToArray(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : new FooIterator, 2), a = ref[0], b = ref[1]; } fun(new FooIterator); diff --git a/crates/swc/tests/tsc-references/es6/destructuring/iterableArrayPattern11/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/es6/destructuring/iterableArrayPattern11/input.ts/es5.2.minified/output.js index bece2eebeb090..57c0261cb9ce2 100644 --- a/crates/swc/tests/tsc-references/es6/destructuring/iterableArrayPattern11/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/es6/destructuring/iterableArrayPattern11/input.ts/es5.2.minified/output.js @@ -84,10 +84,10 @@ var Bar1 = function() { } ], _defineProperties(Constructor.prototype, protoProps), staticProps && _defineProperties(Constructor, staticProps), FooIterator; }(); -!function(param) { - var arr, i, ref = (i = 2, function(arr) { +!function() { + var arr, i, ref = (arr = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : new FooIterator, i = 2, function(arr) { if (Array.isArray(arr)) return arr; - }(arr = void 0 === param ? new FooIterator : param) || function(arr, i) { + }(arr) || function(arr, i) { var _arr = [], _n = !0, _d = !1, _e = void 0; try { for(var _s, _i = arr[Symbol.iterator](); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !i || _arr.length !== i); _n = !0); diff --git a/crates/swc/tests/tsc-references/es6/destructuring/iterableArrayPattern12/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/es6/destructuring/iterableArrayPattern12/input.ts/es5.1.normal/output.js index d211655de6dfc..25b68953c5768 100644 --- a/crates/swc/tests/tsc-references/es6/destructuring/iterableArrayPattern12/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/es6/destructuring/iterableArrayPattern12/input.ts/es5.1.normal/output.js @@ -134,7 +134,7 @@ var FooIterator = /*#__PURE__*/ function() { ]); return FooIterator; }(); -function fun(param) { - var ref = _toArray(param === void 0 ? new FooIterator : param), a = ref[0], b = ref.slice(1); +function fun() { + var ref = _toArray(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : new FooIterator), a = ref[0], b = ref.slice(1); } fun(new FooIterator); diff --git a/crates/swc/tests/tsc-references/es6/destructuring/iterableArrayPattern12/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/es6/destructuring/iterableArrayPattern12/input.ts/es5.2.minified/output.js index d47d6f4a29c57..a50dded1d2217 100644 --- a/crates/swc/tests/tsc-references/es6/destructuring/iterableArrayPattern12/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/es6/destructuring/iterableArrayPattern12/input.ts/es5.2.minified/output.js @@ -84,13 +84,13 @@ var Bar1 = function() { } ], _defineProperties(Constructor.prototype, protoProps), staticProps && _defineProperties(Constructor, staticProps), FooIterator; }(); -!function(param) { - var arr, ref = function(arr) { +!function() { + var arr, ref = (arr = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : new FooIterator, function(arr) { if (Array.isArray(arr)) return arr; - }(arr = void 0 === param ? new FooIterator : param) || function(iter) { + }(arr) || function(iter) { if (Symbol.iterator in Object(iter) || "[object Arguments]" === Object.prototype.toString.call(iter)) return Array.from(iter); }(arr) || function() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); - }(); + }()); ref[0], ref.slice(1); }(new FooIterator); diff --git a/crates/swc/tests/tsc-references/es6/destructuring/iterableArrayPattern9/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/es6/destructuring/iterableArrayPattern9/input.ts/es5.1.normal/output.js index c2a72b82f3474..f942c8a133217 100644 --- a/crates/swc/tests/tsc-references/es6/destructuring/iterableArrayPattern9/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/es6/destructuring/iterableArrayPattern9/input.ts/es5.1.normal/output.js @@ -115,8 +115,8 @@ function _createSuper(Derived) { }; } //@target: ES6 -function fun(param) { - var ref = _slicedToArray(param === void 0 ? new FooIterator : param, 2), a = ref[0], b = ref[1]; +function fun() { + var ref = _slicedToArray(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : new FooIterator, 2), a = ref[0], b = ref[1]; } var Bar = function Bar() { "use strict"; diff --git a/crates/swc/tests/tsc-references/es6/destructuring/restElementWithNullInitializer/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/es6/destructuring/restElementWithNullInitializer/input.ts/es5.1.normal/output.js index f92593bfb488f..b17fcdfe13954 100644 --- a/crates/swc/tests/tsc-references/es6/destructuring/restElementWithNullInitializer/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/es6/destructuring/restElementWithNullInitializer/input.ts/es5.1.normal/output.js @@ -10,16 +10,16 @@ function _nonIterableRest() { function _toArray(arr) { return _arrayWithHoles(arr) || _iterableToArray(arr) || _nonIterableRest(); } -function foo1(param) { - var ref = _toArray(param === void 0 ? null : param), r = ref.slice(0); +function foo1() { + var ref = _toArray(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : null), r = ref.slice(0); } -function foo2(param) { - var ref = _toArray(param === void 0 ? undefined : param), r = ref.slice(0); +function foo2() { + var ref = _toArray(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : undefined), r = ref.slice(0); } -function foo3(param) { - var ref = _toArray(param === void 0 ? { - } : param), r = ref.slice(0); +function foo3() { + var ref = _toArray(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { + }), r = ref.slice(0); } -function foo4(param) { - var ref = _toArray(param === void 0 ? [] : param), r = ref.slice(0); +function foo4() { + var ref = _toArray(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : []), r = ref.slice(0); } diff --git a/crates/swc/tests/tsc-references/expressions/contextualTyping/functionExpressionContextualTyping1/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/expressions/contextualTyping/functionExpressionContextualTyping1/input.ts/es5.1.normal/output.js index 131a70f70967c..92df75c4c107c 100644 --- a/crates/swc/tests/tsc-references/expressions/contextualTyping/functionExpressionContextualTyping1/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/expressions/contextualTyping/functionExpressionContextualTyping1/input.ts/es5.1.normal/output.js @@ -67,12 +67,12 @@ b2 = function(foo, bar) { var b3; b3 = function(name, number) { }; -var b4 = function(param) { - var number = param === void 0 ? 1 : param; +var b4 = function() { + var number = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 1; return "hello"; }; -var b5 = function(param) { - var number = param === void 0 ? "string" : param; +var b5 = function() { + var number = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "string"; return "hello"; }; // A contextual signature S is extracted from a function type T as follows: diff --git a/crates/swc/tests/tsc-references/expressions/contextualTyping/generatedContextualTyping/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/expressions/contextualTyping/generatedContextualTyping/input.ts/es5.1.normal/output.js index 76d4748aa7ab7..687fe8dcc059d 100644 --- a/crates/swc/tests/tsc-references/expressions/contextualTyping/generatedContextualTyping/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/expressions/contextualTyping/generatedContextualTyping/input.ts/es5.1.normal/output.js @@ -844,461 +844,461 @@ x84.member = { ]; } }; -var x85 = function x85(param) { +var x85 = function x85() { "use strict"; - var parm = param === void 0 ? function() { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function() { return [ d1, d2 ]; - } : param; + }; _classCallCheck(this, x85); }; -var x86 = function x86(param) { +var x86 = function x86() { "use strict"; - var parm = param === void 0 ? function() { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function() { return [ d1, d2 ]; - } : param; + }; _classCallCheck(this, x86); }; -var x87 = function x87(param) { +var x87 = function x87() { "use strict"; - var parm = param === void 0 ? function named() { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function named() { return [ d1, d2 ]; - } : param; + }; _classCallCheck(this, x87); }; -var x88 = function x88(param) { +var x88 = function x88() { "use strict"; - var parm = param === void 0 ? function() { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function() { return [ d1, d2 ]; - } : param; + }; _classCallCheck(this, x88); }; -var x89 = function x89(param) { +var x89 = function x89() { "use strict"; - var parm = param === void 0 ? function() { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function() { return [ d1, d2 ]; - } : param; + }; _classCallCheck(this, x89); }; -var x90 = function x90(param) { +var x90 = function x90() { "use strict"; - var parm = param === void 0 ? function named() { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function named() { return [ d1, d2 ]; - } : param; + }; _classCallCheck(this, x90); }; -var x91 = function x91(param) { +var x91 = function x91() { "use strict"; - var parm = param === void 0 ? [ + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [ d1, d2 - ] : param; + ]; _classCallCheck(this, x91); }; -var x92 = function x92(param) { +var x92 = function x92() { "use strict"; - var parm = param === void 0 ? [ + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [ d1, d2 - ] : param; + ]; _classCallCheck(this, x92); }; -var x93 = function x93(param) { +var x93 = function x93() { "use strict"; - var parm = param === void 0 ? [ + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [ d1, d2 - ] : param; + ]; _classCallCheck(this, x93); }; -var x94 = function x94(param) { +var x94 = function x94() { "use strict"; - var parm = param === void 0 ? { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { n: [ d1, d2 ] - } : param; + }; _classCallCheck(this, x94); }; -var x95 = function x95(param) { +var x95 = function x95() { "use strict"; - var parm = param === void 0 ? function(n) { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function(n) { var n; return null; - } : param; + }; _classCallCheck(this, x95); }; -var x96 = function x96(param) { +var x96 = function x96() { "use strict"; - var parm = param === void 0 ? { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { func: function(n) { return [ d1, d2 ]; } - } : param; + }; _classCallCheck(this, x96); }; -var x97 = function x97(param) { +var x97 = function x97() { "use strict"; - var parm = param === void 0 ? function() { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function() { return [ d1, d2 ]; - } : param; + }; _classCallCheck(this, x97); this.parm = parm; }; -var x98 = function x98(param) { +var x98 = function x98() { "use strict"; - var parm = param === void 0 ? function() { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function() { return [ d1, d2 ]; - } : param; + }; _classCallCheck(this, x98); this.parm = parm; }; -var x99 = function x99(param) { +var x99 = function x99() { "use strict"; - var parm = param === void 0 ? function named() { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function named() { return [ d1, d2 ]; - } : param; + }; _classCallCheck(this, x99); this.parm = parm; }; -var x100 = function x100(param) { +var x100 = function x100() { "use strict"; - var parm = param === void 0 ? function() { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function() { return [ d1, d2 ]; - } : param; + }; _classCallCheck(this, x100); this.parm = parm; }; -var x101 = function x101(param) { +var x101 = function x101() { "use strict"; - var parm = param === void 0 ? function() { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function() { return [ d1, d2 ]; - } : param; + }; _classCallCheck(this, x101); this.parm = parm; }; -var x102 = function x102(param) { +var x102 = function x102() { "use strict"; - var parm = param === void 0 ? function named() { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function named() { return [ d1, d2 ]; - } : param; + }; _classCallCheck(this, x102); this.parm = parm; }; -var x103 = function x103(param) { +var x103 = function x103() { "use strict"; - var parm = param === void 0 ? [ + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [ d1, d2 - ] : param; + ]; _classCallCheck(this, x103); this.parm = parm; }; -var x104 = function x104(param) { +var x104 = function x104() { "use strict"; - var parm = param === void 0 ? [ + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [ d1, d2 - ] : param; + ]; _classCallCheck(this, x104); this.parm = parm; }; -var x105 = function x105(param) { +var x105 = function x105() { "use strict"; - var parm = param === void 0 ? [ + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [ d1, d2 - ] : param; + ]; _classCallCheck(this, x105); this.parm = parm; }; -var x106 = function x106(param) { +var x106 = function x106() { "use strict"; - var parm = param === void 0 ? { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { n: [ d1, d2 ] - } : param; + }; _classCallCheck(this, x106); this.parm = parm; }; -var x107 = function x107(param) { +var x107 = function x107() { "use strict"; - var parm = param === void 0 ? function(n) { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function(n) { var n; return null; - } : param; + }; _classCallCheck(this, x107); this.parm = parm; }; -var x108 = function x108(param) { +var x108 = function x108() { "use strict"; - var parm = param === void 0 ? { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { func: function(n) { return [ d1, d2 ]; } - } : param; + }; _classCallCheck(this, x108); this.parm = parm; }; -var x109 = function x109(param) { +var x109 = function x109() { "use strict"; - var parm = param === void 0 ? function() { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function() { return [ d1, d2 ]; - } : param; + }; _classCallCheck(this, x109); this.parm = parm; }; -var x110 = function x110(param) { +var x110 = function x110() { "use strict"; - var parm = param === void 0 ? function() { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function() { return [ d1, d2 ]; - } : param; + }; _classCallCheck(this, x110); this.parm = parm; }; -var x111 = function x111(param) { +var x111 = function x111() { "use strict"; - var parm = param === void 0 ? function named() { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function named() { return [ d1, d2 ]; - } : param; + }; _classCallCheck(this, x111); this.parm = parm; }; -var x112 = function x112(param) { +var x112 = function x112() { "use strict"; - var parm = param === void 0 ? function() { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function() { return [ d1, d2 ]; - } : param; + }; _classCallCheck(this, x112); this.parm = parm; }; -var x113 = function x113(param) { +var x113 = function x113() { "use strict"; - var parm = param === void 0 ? function() { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function() { return [ d1, d2 ]; - } : param; + }; _classCallCheck(this, x113); this.parm = parm; }; -var x114 = function x114(param) { +var x114 = function x114() { "use strict"; - var parm = param === void 0 ? function named() { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function named() { return [ d1, d2 ]; - } : param; + }; _classCallCheck(this, x114); this.parm = parm; }; -var x115 = function x115(param) { +var x115 = function x115() { "use strict"; - var parm = param === void 0 ? [ + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [ d1, d2 - ] : param; + ]; _classCallCheck(this, x115); this.parm = parm; }; -var x116 = function x116(param) { +var x116 = function x116() { "use strict"; - var parm = param === void 0 ? [ + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [ d1, d2 - ] : param; + ]; _classCallCheck(this, x116); this.parm = parm; }; -var x117 = function x117(param) { +var x117 = function x117() { "use strict"; - var parm = param === void 0 ? [ + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [ d1, d2 - ] : param; + ]; _classCallCheck(this, x117); this.parm = parm; }; -var x118 = function x118(param) { +var x118 = function x118() { "use strict"; - var parm = param === void 0 ? { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { n: [ d1, d2 ] - } : param; + }; _classCallCheck(this, x118); this.parm = parm; }; -var x119 = function x119(param) { +var x119 = function x119() { "use strict"; - var parm = param === void 0 ? function(n) { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function(n) { var n; return null; - } : param; + }; _classCallCheck(this, x119); this.parm = parm; }; -var x120 = function x120(param) { +var x120 = function x120() { "use strict"; - var parm = param === void 0 ? { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { func: function(n) { return [ d1, d2 ]; } - } : param; + }; _classCallCheck(this, x120); this.parm = parm; }; -function x121(param) { - var parm = param === void 0 ? function() { +function x121() { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function() { return [ d1, d2 ]; - } : param; + }; } -function x122(param) { - var parm = param === void 0 ? function() { +function x122() { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function() { return [ d1, d2 ]; - } : param; + }; } -function x123(param) { - var parm = param === void 0 ? function named() { +function x123() { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function named() { return [ d1, d2 ]; - } : param; + }; } -function x124(param) { - var parm = param === void 0 ? function() { +function x124() { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function() { return [ d1, d2 ]; - } : param; + }; } -function x125(param) { - var parm = param === void 0 ? function() { +function x125() { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function() { return [ d1, d2 ]; - } : param; + }; } -function x126(param) { - var parm = param === void 0 ? function named() { +function x126() { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function named() { return [ d1, d2 ]; - } : param; + }; } -function x127(param) { - var parm = param === void 0 ? [ +function x127() { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [ d1, d2 - ] : param; + ]; } -function x128(param) { - var parm = param === void 0 ? [ +function x128() { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [ d1, d2 - ] : param; + ]; } -function x129(param) { - var parm = param === void 0 ? [ +function x129() { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [ d1, d2 - ] : param; + ]; } -function x130(param) { - var parm = param === void 0 ? { +function x130() { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { n: [ d1, d2 ] - } : param; + }; } -function x131(param) { - var parm = param === void 0 ? function(n) { +function x131() { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function(n) { var n; return null; - } : param; + }; } -function x132(param) { - var parm = param === void 0 ? { +function x132() { + var parm = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { func: function(n) { return [ d1, d2 ]; } - } : param; + }; } function x133() { return function() { diff --git a/crates/swc/tests/tsc-references/expressions/contextualTyping/generatedContextualTyping/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/expressions/contextualTyping/generatedContextualTyping/input.ts/es5.2.minified/output.js index e0c817c082b70..989ae356a53d3 100644 --- a/crates/swc/tests/tsc-references/expressions/contextualTyping/generatedContextualTyping/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/expressions/contextualTyping/generatedContextualTyping/input.ts/es5.2.minified/output.js @@ -672,220 +672,244 @@ x84.member = { ]; } }; -var x85 = function(param) { +var x85 = function() { "use strict"; - _classCallCheck(this, x85); -}, x86 = function(param) { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0], _classCallCheck(this, x85); +}, x86 = function() { "use strict"; - _classCallCheck(this, x86); -}, x87 = function(param) { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0], _classCallCheck(this, x86); +}, x87 = function() { "use strict"; - _classCallCheck(this, x87); -}, x88 = function(param) { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0], _classCallCheck(this, x87); +}, x88 = function() { "use strict"; - _classCallCheck(this, x88); -}, x89 = function(param) { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0], _classCallCheck(this, x88); +}, x89 = function() { "use strict"; - _classCallCheck(this, x89); -}, x90 = function(param) { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0], _classCallCheck(this, x89); +}, x90 = function() { "use strict"; - _classCallCheck(this, x90); -}, x91 = function(param) { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0], _classCallCheck(this, x90); +}, x91 = function() { "use strict"; - _classCallCheck(this, x91); -}, x92 = function(param) { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0], _classCallCheck(this, x91); +}, x92 = function() { "use strict"; - _classCallCheck(this, x92); -}, x93 = function(param) { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0], _classCallCheck(this, x92); +}, x93 = function() { "use strict"; - _classCallCheck(this, x93); -}, x94 = function(param) { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0], _classCallCheck(this, x93); +}, x94 = function() { "use strict"; - _classCallCheck(this, x94); -}, x95 = function(param) { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0], _classCallCheck(this, x94); +}, x95 = function() { "use strict"; - _classCallCheck(this, x95); -}, x96 = function(param) { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0], _classCallCheck(this, x95); +}, x96 = function() { "use strict"; - _classCallCheck(this, x96); -}, x97 = function(param) { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0], _classCallCheck(this, x96); +}, x97 = function() { "use strict"; - _classCallCheck(this, x97), this.parm = void 0 === param ? function() { + var parm = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : function() { return [ d1, d2 ]; - } : param; -}, x98 = function(param) { + }; + _classCallCheck(this, x97), this.parm = parm; +}, x98 = function() { "use strict"; - _classCallCheck(this, x98), this.parm = void 0 === param ? function() { + var parm = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : function() { return [ d1, d2 ]; - } : param; -}, x99 = function(param) { + }; + _classCallCheck(this, x98), this.parm = parm; +}, x99 = function() { "use strict"; - _classCallCheck(this, x99), this.parm = void 0 === param ? function() { + var parm = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : function() { return [ d1, d2 ]; - } : param; -}, x100 = function(param) { + }; + _classCallCheck(this, x99), this.parm = parm; +}, x100 = function() { "use strict"; - _classCallCheck(this, x100), this.parm = void 0 === param ? function() { + var parm = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : function() { return [ d1, d2 ]; - } : param; -}, x101 = function(param) { + }; + _classCallCheck(this, x100), this.parm = parm; +}, x101 = function() { "use strict"; - _classCallCheck(this, x101), this.parm = void 0 === param ? function() { + var parm = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : function() { return [ d1, d2 ]; - } : param; -}, x102 = function(param) { + }; + _classCallCheck(this, x101), this.parm = parm; +}, x102 = function() { "use strict"; - _classCallCheck(this, x102), this.parm = void 0 === param ? function() { + var parm = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : function() { return [ d1, d2 ]; - } : param; -}, x103 = function(param) { + }; + _classCallCheck(this, x102), this.parm = parm; +}, x103 = function() { "use strict"; - _classCallCheck(this, x103), this.parm = void 0 === param ? [ + var parm = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : [ d1, d2 - ] : param; -}, x104 = function(param) { + ]; + _classCallCheck(this, x103), this.parm = parm; +}, x104 = function() { "use strict"; - _classCallCheck(this, x104), this.parm = void 0 === param ? [ + var parm = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : [ d1, d2 - ] : param; -}, x105 = function(param) { + ]; + _classCallCheck(this, x104), this.parm = parm; +}, x105 = function() { "use strict"; - _classCallCheck(this, x105), this.parm = void 0 === param ? [ + var parm = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : [ d1, d2 - ] : param; -}, x106 = function(param) { + ]; + _classCallCheck(this, x105), this.parm = parm; +}, x106 = function() { "use strict"; - _classCallCheck(this, x106), this.parm = void 0 === param ? { + var parm = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : { n: [ d1, d2 ] - } : param; -}, x107 = function(param) { + }; + _classCallCheck(this, x106), this.parm = parm; +}, x107 = function() { "use strict"; - _classCallCheck(this, x107), this.parm = void 0 === param ? function(n) { + var parm = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : function(n) { return null; - } : param; -}, x108 = function(param) { + }; + _classCallCheck(this, x107), this.parm = parm; +}, x108 = function() { "use strict"; - _classCallCheck(this, x108), this.parm = void 0 === param ? { + var parm = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : { func: function(n) { return [ d1, d2 ]; } - } : param; -}, x109 = function(param) { + }; + _classCallCheck(this, x108), this.parm = parm; +}, x109 = function() { "use strict"; - _classCallCheck(this, x109), this.parm = void 0 === param ? function() { + var parm = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : function() { return [ d1, d2 ]; - } : param; -}, x110 = function(param) { + }; + _classCallCheck(this, x109), this.parm = parm; +}, x110 = function() { "use strict"; - _classCallCheck(this, x110), this.parm = void 0 === param ? function() { + var parm = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : function() { return [ d1, d2 ]; - } : param; -}, x111 = function(param) { + }; + _classCallCheck(this, x110), this.parm = parm; +}, x111 = function() { "use strict"; - _classCallCheck(this, x111), this.parm = void 0 === param ? function() { + var parm = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : function() { return [ d1, d2 ]; - } : param; -}, x112 = function(param) { + }; + _classCallCheck(this, x111), this.parm = parm; +}, x112 = function() { "use strict"; - _classCallCheck(this, x112), this.parm = void 0 === param ? function() { + var parm = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : function() { return [ d1, d2 ]; - } : param; -}, x113 = function(param) { + }; + _classCallCheck(this, x112), this.parm = parm; +}, x113 = function() { "use strict"; - _classCallCheck(this, x113), this.parm = void 0 === param ? function() { + var parm = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : function() { return [ d1, d2 ]; - } : param; -}, x114 = function(param) { + }; + _classCallCheck(this, x113), this.parm = parm; +}, x114 = function() { "use strict"; - _classCallCheck(this, x114), this.parm = void 0 === param ? function() { + var parm = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : function() { return [ d1, d2 ]; - } : param; -}, x115 = function(param) { + }; + _classCallCheck(this, x114), this.parm = parm; +}, x115 = function() { "use strict"; - _classCallCheck(this, x115), this.parm = void 0 === param ? [ + var parm = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : [ d1, d2 - ] : param; -}, x116 = function(param) { + ]; + _classCallCheck(this, x115), this.parm = parm; +}, x116 = function() { "use strict"; - _classCallCheck(this, x116), this.parm = void 0 === param ? [ + var parm = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : [ d1, d2 - ] : param; -}, x117 = function(param) { + ]; + _classCallCheck(this, x116), this.parm = parm; +}, x117 = function() { "use strict"; - _classCallCheck(this, x117), this.parm = void 0 === param ? [ + var parm = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : [ d1, d2 - ] : param; -}, x118 = function(param) { + ]; + _classCallCheck(this, x117), this.parm = parm; +}, x118 = function() { "use strict"; - _classCallCheck(this, x118), this.parm = void 0 === param ? { + var parm = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : { n: [ d1, d2 ] - } : param; -}, x119 = function(param) { + }; + _classCallCheck(this, x118), this.parm = parm; +}, x119 = function() { "use strict"; - _classCallCheck(this, x119), this.parm = void 0 === param ? function(n) { + var parm = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : function(n) { return null; - } : param; -}, x120 = function(param) { + }; + _classCallCheck(this, x119), this.parm = parm; +}, x120 = function() { "use strict"; - _classCallCheck(this, x120), this.parm = void 0 === param ? { + var parm = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : { func: function(n) { return [ d1, d2 ]; } - } : param; + }; + _classCallCheck(this, x120), this.parm = parm; }; (x193 || (x193 = { })).t = function() { diff --git a/crates/swc/tests/tsc-references/expressions/functions/contextuallyTypedIife/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/expressions/functions/contextuallyTypedIife/input.ts/es5.1.normal/output.js index e34719131e762..6811cf933a58b 100644 --- a/crates/swc/tests/tsc-references/expressions/functions/contextuallyTypedIife/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/expressions/functions/contextuallyTypedIife/input.ts/es5.1.normal/output.js @@ -13,12 +13,12 @@ (function(a, b, c) { })("foo", 101, false); // default parameters -(function(param) { - var m = param === void 0 ? 10 : param; +(function() { + var m = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 10; return m + 1; })(12); -(function(param) { - var n = param === void 0 ? 10 : param; +(function() { + var n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 10; return n + 1; })(); // optional parameters @@ -77,18 +77,18 @@ })({ p: 15 }); -(function(param) { - var ref = param === void 0 ? { +(function() { + var ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { r: 18 - } : param, _r = ref.r, r = _r === void 0 ? 17 : _r; + }, _r = ref.r, r = _r === void 0 ? 17 : _r; return r; })({ r: 19 }); -(function(param) { - var ref = param === void 0 ? { +(function() { + var ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { u: 23 - } : param, _u = ref.u, u = _u === void 0 ? 22 : _u; + }, _u = ref.u, u = _u === void 0 ? 22 : _u; return u; })(); // contextually typed parameters. diff --git a/crates/swc/tests/tsc-references/expressions/functions/contextuallyTypedIife/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/expressions/functions/contextuallyTypedIife/input.ts/es5.2.minified/output.js index c394ee3b3215f..bd6f01f9e1f88 100644 --- a/crates/swc/tests/tsc-references/expressions/functions/contextuallyTypedIife/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/expressions/functions/contextuallyTypedIife/input.ts/es5.2.minified/output.js @@ -1,5 +1,8 @@ -var param; (function() { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0]; +})(12), (function() { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0]; +})(), (function() { for(var _len = arguments.length, numbers = new Array(_len), _key = 0; _key < _len; _key++)numbers[_key] = arguments[_key]; numbers.every(function(n) { return n > 0; @@ -16,9 +19,19 @@ var param; }); })(), (function(first) { for(var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++)rest[_key - 1] = arguments[_key]; -})(8, 9, 10), (void 0 === param ? { - u: 23 -} : param).u, (function(f) { +})(8, 9, 10), (function() { + var ref = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : { + r: 18 + }; + ref.r; +})({ + r: 19 +}), (function() { + var ref = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : { + u: 23 + }; + ref.u; +})(), (function(f) { f(12); })(function(i) { return i; diff --git a/crates/swc/tests/tsc-references/expressions/functions/contextuallyTypedIifeStrict/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/expressions/functions/contextuallyTypedIifeStrict/input.ts/es5.1.normal/output.js index 481c1067b9921..ef6fc53c45e6f 100644 --- a/crates/swc/tests/tsc-references/expressions/functions/contextuallyTypedIifeStrict/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/expressions/functions/contextuallyTypedIifeStrict/input.ts/es5.1.normal/output.js @@ -14,12 +14,12 @@ (function(a, b, c) { })("foo", 101, false); // default parameters -(function(param) { - var m = param === void 0 ? 10 : param; +(function() { + var m = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 10; return m + 1; })(12); -(function(param) { - var n = param === void 0 ? 10 : param; +(function() { + var n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 10; return n + 1; })(); // optional parameters @@ -78,18 +78,18 @@ })({ p: 15 }); -(function(param) { - var ref = param === void 0 ? { +(function() { + var ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { r: 18 - } : param, _r = ref.r, r = _r === void 0 ? 17 : _r; + }, _r = ref.r, r = _r === void 0 ? 17 : _r; return r; })({ r: 19 }); -(function(param) { - var ref = param === void 0 ? { +(function() { + var ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { u: 23 - } : param, _u = ref.u, u = _u === void 0 ? 22 : _u; + }, _u = ref.u, u = _u === void 0 ? 22 : _u; return u; })(); // contextually typed parameters. diff --git a/crates/swc/tests/tsc-references/expressions/functions/contextuallyTypedIifeStrict/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/expressions/functions/contextuallyTypedIifeStrict/input.ts/es5.2.minified/output.js index c394ee3b3215f..bd6f01f9e1f88 100644 --- a/crates/swc/tests/tsc-references/expressions/functions/contextuallyTypedIifeStrict/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/expressions/functions/contextuallyTypedIifeStrict/input.ts/es5.2.minified/output.js @@ -1,5 +1,8 @@ -var param; (function() { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0]; +})(12), (function() { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0]; +})(), (function() { for(var _len = arguments.length, numbers = new Array(_len), _key = 0; _key < _len; _key++)numbers[_key] = arguments[_key]; numbers.every(function(n) { return n > 0; @@ -16,9 +19,19 @@ var param; }); })(), (function(first) { for(var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++)rest[_key - 1] = arguments[_key]; -})(8, 9, 10), (void 0 === param ? { - u: 23 -} : param).u, (function(f) { +})(8, 9, 10), (function() { + var ref = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : { + r: 18 + }; + ref.r; +})({ + r: 19 +}), (function() { + var ref = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : { + u: 23 + }; + ref.u; +})(), (function(f) { f(12); })(function(i) { return i; diff --git a/crates/swc/tests/tsc-references/expressions/nullishCoalescingOperator/nullishCoalescingOperator6/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/expressions/nullishCoalescingOperator/nullishCoalescingOperator6/input.ts/es5.1.normal/output.js index 9a6185f44e86f..a7f05f24447e5 100644 --- a/crates/swc/tests/tsc-references/expressions/nullishCoalescingOperator/nullishCoalescingOperator6/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/expressions/nullishCoalescingOperator/nullishCoalescingOperator6/input.ts/es5.1.normal/output.js @@ -1,4 +1,4 @@ // @strict: true -function foo1(foo, param) { - var bar = param === void 0 ? foo !== null && foo !== void 0 ? foo : "bar" : param; +function foo1(foo) { + var bar = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : foo !== null && foo !== void 0 ? foo : "bar"; } diff --git a/crates/swc/tests/tsc-references/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterInitializer.2/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterInitializer.2/input.ts/es5.1.normal/output.js index 960be86e5972f..3eab1a58fc709 100644 --- a/crates/swc/tests/tsc-references/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterInitializer.2/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterInitializer.2/input.ts/es5.1.normal/output.js @@ -6,13 +6,13 @@ var a = function() { return undefined; }; var ref; -(function(param) { - var b = param === void 0 ? (ref = a()) !== null && ref !== void 0 ? ref : "d" : param; +(function() { + var b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : (ref = a()) !== null && ref !== void 0 ? ref : "d"; var a1; })(); var x = ""; var ref1; -(function(param, param1) { - var b = param === void 0 ? (ref1 = a()) !== null && ref1 !== void 0 ? ref1 : "d" : param, d = param1 === void 0 ? x : param1; +(function() { + var b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : (ref1 = a()) !== null && ref1 !== void 0 ? ref1 : "d", d = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : x; var x1; })(); diff --git a/crates/swc/tests/tsc-references/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterInitializer.2/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterInitializer.2/input.ts/es5.2.minified/output.js index b5ac7bfed3132..5790c6a8318eb 100644 --- a/crates/swc/tests/tsc-references/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterInitializer.2/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterInitializer.2/input.ts/es5.2.minified/output.js @@ -1,3 +1,7 @@ -var param, param1, ref, ref1, param2, a = function() { +var ref, ref1, a = function() { }; -void 0 === param2 && null !== (ref = a()) && void 0 !== ref, void 0 === param1, void 0 === param && null !== (ref1 = a()) && void 0 !== ref1; +!function() { + arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : null !== (ref = a()) && void 0 !== ref; +}(), (function() { + arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : null !== (ref1 = a()) && void 0 !== ref1, arguments.length > 1 && void 0 !== arguments[1] && arguments[1]; +})(); diff --git a/crates/swc/tests/tsc-references/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterInitializer/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterInitializer/input.ts/es5.1.normal/output.js index 12a9481cc1710..cd442e2974f2e 100644 --- a/crates/swc/tests/tsc-references/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterInitializer/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterInitializer/input.ts/es5.1.normal/output.js @@ -5,6 +5,6 @@ var a = function() { return undefined; }; var ref; -(function(param) { - var b = param === void 0 ? (ref = a()) !== null && ref !== void 0 ? ref : "d" : param; +(function() { + var b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : (ref = a()) !== null && ref !== void 0 ? ref : "d"; })(); diff --git a/crates/swc/tests/tsc-references/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterInitializer/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterInitializer/input.ts/es5.2.minified/output.js index e69de29bb2d1d..9801756bd43ac 100644 --- a/crates/swc/tests/tsc-references/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterInitializer/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterInitializer/input.ts/es5.2.minified/output.js @@ -0,0 +1,5 @@ +var ref, a = function() { +}; +!function() { + arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : null !== (ref = a()) && void 0 !== ref; +}(); diff --git a/crates/swc/tests/tsc-references/expressions/optionalChaining/optionalChainingInParameterBindingPattern.2/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/expressions/optionalChaining/optionalChainingInParameterBindingPattern.2/input.ts/es5.1.normal/output.js index 8a53dd6e223a6..e9c1811c41d57 100644 --- a/crates/swc/tests/tsc-references/expressions/optionalChaining/optionalChainingInParameterBindingPattern.2/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/expressions/optionalChaining/optionalChainingInParameterBindingPattern.2/input.ts/es5.1.normal/output.js @@ -11,7 +11,7 @@ var a = function() { var a; })(); var x = ""; -(function(param, param1) { - var c = param[(ref1 = a()) === null || ref1 === void 0 ? void 0 : ref1.d], d = param1 === void 0 ? x : param1; +(function(param) { + var c = param[(ref1 = a()) === null || ref1 === void 0 ? void 0 : ref1.d], d = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : x; var x1; })(); diff --git a/crates/swc/tests/tsc-references/expressions/optionalChaining/optionalChainingInParameterBindingPattern.2/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/expressions/optionalChaining/optionalChainingInParameterBindingPattern.2/input.ts/es5.2.minified/output.js index b1daaa6eb496b..68c23844bebec 100644 --- a/crates/swc/tests/tsc-references/expressions/optionalChaining/optionalChainingInParameterBindingPattern.2/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/expressions/optionalChaining/optionalChainingInParameterBindingPattern.2/input.ts/es5.2.minified/output.js @@ -1,3 +1,5 @@ -var param, ref, ref1, a = function() { +var ref, ref1, a = function() { }; -(void 0)[null === (ref = a()) || void 0 === ref ? void 0 : ref.d], void 0 === param, (void 0)[null === (ref1 = a()) || void 0 === ref1 ? void 0 : ref1.d]; +(void 0)[null === (ref = a()) || void 0 === ref ? void 0 : ref.d], (function(param) { + (void 0)[null === (ref1 = a()) || void 0 === ref1 ? void 0 : ref1.d], arguments.length > 1 && void 0 !== arguments[1] && arguments[1]; +})(); diff --git a/crates/swc/tests/tsc-references/expressions/optionalChaining/optionalChainingInParameterInitializer.2/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/expressions/optionalChaining/optionalChainingInParameterInitializer.2/input.ts/es5.1.normal/output.js index 8219a33f49444..317e27baa3924 100644 --- a/crates/swc/tests/tsc-references/expressions/optionalChaining/optionalChainingInParameterInitializer.2/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/expressions/optionalChaining/optionalChainingInParameterInitializer.2/input.ts/es5.1.normal/output.js @@ -6,12 +6,12 @@ var ref, ref1; var a = function() { return undefined; }; -(function(param) { - var b = param === void 0 ? (ref = a()) === null || ref === void 0 ? void 0 : ref.d : param; +(function() { + var b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : (ref = a()) === null || ref === void 0 ? void 0 : ref.d; var a1; })(); var x = ""; -(function(param, param1) { - var b = param === void 0 ? (ref1 = a()) === null || ref1 === void 0 ? void 0 : ref1.d : param, d = param1 === void 0 ? x : param1; +(function() { + var b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : (ref1 = a()) === null || ref1 === void 0 ? void 0 : ref1.d, d = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : x; var x1; })(); diff --git a/crates/swc/tests/tsc-references/expressions/optionalChaining/optionalChainingInParameterInitializer.2/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/expressions/optionalChaining/optionalChainingInParameterInitializer.2/input.ts/es5.2.minified/output.js index 6150ed55be05c..5602acb3ddcd5 100644 --- a/crates/swc/tests/tsc-references/expressions/optionalChaining/optionalChainingInParameterInitializer.2/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/expressions/optionalChaining/optionalChainingInParameterInitializer.2/input.ts/es5.2.minified/output.js @@ -1,3 +1,7 @@ -var param, param1, ref, ref1, param2, a = function() { +var ref, ref1, a = function() { }; -void 0 === param2 && (null === (ref = a()) || void 0 === ref || ref.d), void 0 === param1, void 0 === param && (null === (ref1 = a()) || void 0 === ref1 || ref1.d); +!function() { + arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : null === (ref = a()) || void 0 === ref || ref.d; +}(), (function() { + arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : null === (ref1 = a()) || void 0 === ref1 || ref1.d, arguments.length > 1 && void 0 !== arguments[1] && arguments[1]; +})(); diff --git a/crates/swc/tests/tsc-references/expressions/optionalChaining/optionalChainingInParameterInitializer/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/expressions/optionalChaining/optionalChainingInParameterInitializer/input.ts/es5.1.normal/output.js index 74a2a07a99d6e..49dd2bf4ba546 100644 --- a/crates/swc/tests/tsc-references/expressions/optionalChaining/optionalChainingInParameterInitializer/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/expressions/optionalChaining/optionalChainingInParameterInitializer/input.ts/es5.1.normal/output.js @@ -5,6 +5,6 @@ var ref; var a = function() { return undefined; }; -(function(param) { - var b = param === void 0 ? (ref = a()) === null || ref === void 0 ? void 0 : ref.d : param; +(function() { + var b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : (ref = a()) === null || ref === void 0 ? void 0 : ref.d; })(); diff --git a/crates/swc/tests/tsc-references/expressions/optionalChaining/optionalChainingInParameterInitializer/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/expressions/optionalChaining/optionalChainingInParameterInitializer/input.ts/es5.2.minified/output.js index e69de29bb2d1d..c89d8ff2b85d0 100644 --- a/crates/swc/tests/tsc-references/expressions/optionalChaining/optionalChainingInParameterInitializer/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/expressions/optionalChaining/optionalChainingInParameterInitializer/input.ts/es5.2.minified/output.js @@ -0,0 +1,5 @@ +var ref, a = function() { +}; +!function() { + arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : null === (ref = a()) || void 0 === ref || ref.d; +}(); diff --git a/crates/swc/tests/tsc-references/expressions/thisKeyword/typeOfThis/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/expressions/thisKeyword/typeOfThis/input.ts/es5.1.normal/output.js index 8e034dfc65de1..0c4c370a1a8d3 100644 --- a/crates/swc/tests/tsc-references/expressions/thisKeyword/typeOfThis/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/expressions/thisKeyword/typeOfThis/input.ts/es5.1.normal/output.js @@ -38,8 +38,8 @@ var MyTestClass = // @target: esnext { //type of 'this' in member function param list is the class instance type key: "memberFunc", - value: function memberFunc(param) { - var t = param === void 0 ? this : param; + value: function memberFunc() { + var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this; var t; //type of 'this' in member function body is the class instance type var p = this; @@ -65,8 +65,8 @@ var MyTestClass = // @target: esnext { key: "staticFn", value: //type of 'this' in static function param list is constructor function type - function staticFn(param) { - var t = param === void 0 ? this : param; + function staticFn() { + var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this; var t; var t = MyTestClass; t.staticCanary; @@ -117,8 +117,8 @@ var MyGenericTestClass = /*#__PURE__*/ function() { { //type of 'this' in member function param list is the class instance type key: "memberFunc", - value: function memberFunc(param) { - var t = param === void 0 ? this : param; + value: function memberFunc() { + var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this; var t; //type of 'this' in member function body is the class instance type var p = this; @@ -144,8 +144,8 @@ var MyGenericTestClass = /*#__PURE__*/ function() { { key: "staticFn", value: //type of 'this' in static function param list is constructor function type - function staticFn(param) { - var t = param === void 0 ? this : param; + function staticFn() { + var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this; var t; var t = MyGenericTestClass; t.staticCanary; @@ -178,8 +178,8 @@ var MyGenericTestClass = /*#__PURE__*/ function() { return MyGenericTestClass; }(); //type of 'this' in a function declaration param list is Any -function fn(param) { - var s = param === void 0 ? this : param; +function fn() { + var s = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this; var s; s.spaaaaaaace = 4; //type of 'this' in a function declaration body is Any @@ -188,8 +188,8 @@ function fn(param) { this.spaaaaace = 4; } //type of 'this' in a function expression param list list is Any -var q1 = function q1(param) { - var s = param === void 0 ? this : param; +var q1 = function q1() { + var s = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this; var s; s.spaaaaaaace = 4; //type of 'this' in a function expression body is Any @@ -198,8 +198,8 @@ var q1 = function q1(param) { this.spaaaaace = 4; }; //type of 'this' in a fat arrow expression param list is typeof globalThis -var q2 = function(param) { - var s = param === void 0 ? _this1 : param; +var q2 = function() { + var s = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : _this1; var s; s.spaaaaaaace = 4; //type of 'this' in a fat arrow expression body is typeof globalThis diff --git a/crates/swc/tests/tsc-references/expressions/thisKeyword/typeOfThis/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/expressions/thisKeyword/typeOfThis/input.ts/es5.2.minified/output.js index c9dce795c5a4c..9d13713972196 100644 --- a/crates/swc/tests/tsc-references/expressions/thisKeyword/typeOfThis/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/expressions/thisKeyword/typeOfThis/input.ts/es5.2.minified/output.js @@ -19,7 +19,8 @@ var MyTestClass = function() { return _createClass(MyTestClass, [ { key: "memberFunc", - value: function(param) { + value: function() { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0]; } }, { @@ -34,8 +35,8 @@ var MyTestClass = function() { ], [ { key: "staticFn", - value: function(param) { - var t, p, t = void 0 === param ? this : param, t = MyTestClass; + value: function() { + var t, p, t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : this, t = MyTestClass; t.staticCanary; var p = this, p = MyTestClass; p.staticCanary; @@ -62,7 +63,8 @@ var MyTestClass = function() { return _createClass(MyGenericTestClass, [ { key: "memberFunc", - value: function(param) { + value: function() { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0]; } }, { @@ -77,8 +79,8 @@ var MyTestClass = function() { ], [ { key: "staticFn", - value: function(param) { - var t, p, t = void 0 === param ? this : param, t = MyGenericTestClass; + value: function() { + var t, p, t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : this, t = MyGenericTestClass; t.staticCanary; var p = this, p = MyGenericTestClass; p.staticCanary; diff --git a/crates/swc/tests/tsc-references/expressions/thisKeyword/typeOfThisInConstructorParamList/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/expressions/thisKeyword/typeOfThisInConstructorParamList/input.ts/es5.1.normal/output.js index 1fbb8eacf9950..5c4b624047e1b 100644 --- a/crates/swc/tests/tsc-references/expressions/thisKeyword/typeOfThisInConstructorParamList/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/expressions/thisKeyword/typeOfThisInConstructorParamList/input.ts/es5.1.normal/output.js @@ -3,8 +3,8 @@ function _classCallCheck(instance, Constructor) { throw new TypeError("Cannot call a class as a function"); } } -var ErrClass = function ErrClass(param) { +var ErrClass = function ErrClass() { "use strict"; - var f = param === void 0 ? this : param; + var f = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this; _classCallCheck(this, ErrClass); }; diff --git a/crates/swc/tests/tsc-references/expressions/thisKeyword/typeOfThisInConstructorParamList/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/expressions/thisKeyword/typeOfThisInConstructorParamList/input.ts/es5.2.minified/output.js index cf51aff05b8df..fd1d86b8b88ce 100644 --- a/crates/swc/tests/tsc-references/expressions/thisKeyword/typeOfThisInConstructorParamList/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/expressions/thisKeyword/typeOfThisInConstructorParamList/input.ts/es5.2.minified/output.js @@ -1,6 +1,6 @@ -var ErrClass = function(param) { +var ErrClass = function() { "use strict"; - !function(instance, Constructor) { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0], (function(instance, Constructor) { if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function"); - }(this, ErrClass); + })(this, ErrClass); }; diff --git a/crates/swc/tests/tsc-references/externalModules/es6/es6modulekindWithES5Target6/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/externalModules/es6/es6modulekindWithES5Target6/input.ts/es5.1.normal/output.js index 775a54a390a46..2fcf95c6894ca 100644 --- a/crates/swc/tests/tsc-references/externalModules/es6/es6modulekindWithES5Target6/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/externalModules/es6/es6modulekindWithES5Target6/input.ts/es5.1.normal/output.js @@ -1,13 +1,13 @@ // @target: es5 // @module: es2015 -export function f1(param) { - var d = param === void 0 ? 0 : param; +export function f1() { + var d = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0; } export function f2() { for(var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++){ arg[_key] = arguments[_key]; } } -export default function f3(param) { - var d = param === void 0 ? 0 : param; +export default function f3() { + var d = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0; }; diff --git a/crates/swc/tests/tsc-references/externalModules/es6/es6modulekindWithES5Target6/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/externalModules/es6/es6modulekindWithES5Target6/input.ts/es5.2.minified/output.js index 07b5099133a98..9266e6c4fb665 100644 --- a/crates/swc/tests/tsc-references/externalModules/es6/es6modulekindWithES5Target6/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/externalModules/es6/es6modulekindWithES5Target6/input.ts/es5.2.minified/output.js @@ -1,7 +1,9 @@ export function f1() { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0]; } export function f2() { for(var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++)arg[_key] = arguments[_key]; } -export default function f3(param) { +export default function f3() { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0]; }; diff --git a/crates/swc/tests/tsc-references/externalModules/esnext/esnextmodulekindWithES5Target6/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/externalModules/esnext/esnextmodulekindWithES5Target6/input.ts/es5.1.normal/output.js index 66d766e78327a..fabff1bc94ed0 100644 --- a/crates/swc/tests/tsc-references/externalModules/esnext/esnextmodulekindWithES5Target6/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/externalModules/esnext/esnextmodulekindWithES5Target6/input.ts/es5.1.normal/output.js @@ -1,13 +1,13 @@ // @target: es5 // @module: esnext -export function f1(param) { - var d = param === void 0 ? 0 : param; +export function f1() { + var d = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0; } export function f2() { for(var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++){ arg[_key] = arguments[_key]; } } -export default function f3(param) { - var d = param === void 0 ? 0 : param; +export default function f3() { + var d = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0; }; diff --git a/crates/swc/tests/tsc-references/externalModules/esnext/esnextmodulekindWithES5Target6/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/externalModules/esnext/esnextmodulekindWithES5Target6/input.ts/es5.2.minified/output.js index 07b5099133a98..9266e6c4fb665 100644 --- a/crates/swc/tests/tsc-references/externalModules/esnext/esnextmodulekindWithES5Target6/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/externalModules/esnext/esnextmodulekindWithES5Target6/input.ts/es5.2.minified/output.js @@ -1,7 +1,9 @@ export function f1() { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0]; } export function f2() { for(var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++)arg[_key] = arguments[_key]; } -export default function f3(param) { +export default function f3() { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0]; }; diff --git a/crates/swc/tests/tsc-references/functions/functionImplementationErrors/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/functions/functionImplementationErrors/input.ts/es5.1.normal/output.js index 36ff139cab5eb..1c2e9ff3f9b4b 100644 --- a/crates/swc/tests/tsc-references/functions/functionImplementationErrors/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/functions/functionImplementationErrors/input.ts/es5.1.normal/output.js @@ -100,13 +100,13 @@ function f5() { } var m; // Function signature with parameter initializer referencing in scope local variable -function f6(param) { - var n = param === void 0 ? m : param; +function f6() { + var n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : m; var m1 = 4; } // Function signature with initializer referencing other parameter to the right -function f7(param, m2) { - var n = param === void 0 ? m : param; +function f7() { + var n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : m, m2 = arguments.length > 1 ? arguments[1] : void 0; } // FunctionExpression with non -void return type annotation with a throw, no return, and other code // Should be error but isn't diff --git a/crates/swc/tests/tsc-references/functions/functionImplementations/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/functions/functionImplementations/input.ts/es5.1.normal/output.js index e4219b2c5ed2f..c8a5e565be635 100644 --- a/crates/swc/tests/tsc-references/functions/functionImplementations/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/functions/functionImplementations/input.ts/es5.1.normal/output.js @@ -166,23 +166,23 @@ function thisFunc() { var x; } // Function signature with optional parameter, no type annotation and initializer has initializer's type -function opt1(param) { - var n = param === void 0 ? 4 : param; +function opt1() { + var n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 4; var m = n; var m; } // Function signature with optional parameter, no type annotation and initializer has initializer's widened type -function opt2(param) { - var n = param === void 0 ? { +function opt2() { + var n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { x: null, y: undefined - } : param; + }; var m = n; var m; } // Function signature with initializer referencing other parameter to the left -function opt3(n, param) { - var m = param === void 0 ? n : param; +function opt3(n) { + var m = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : n; var y = m; var y; } diff --git a/crates/swc/tests/tsc-references/functions/parameterInitializersBackwardReferencing/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/functions/parameterInitializersBackwardReferencing/input.ts/es5.1.normal/output.js index df007956217ff..33df602c29365 100644 --- a/crates/swc/tests/tsc-references/functions/parameterInitializersBackwardReferencing/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/functions/parameterInitializersBackwardReferencing/input.ts/es5.1.normal/output.js @@ -2,17 +2,17 @@ // @noEmit: true // @noTypesAndSymbols: true // https://github.com/microsoft/TypeScript/issues/38243 -function test0(param) { - var ref = param === void 0 ? { - } : param, _a = ref.a, a = _a === void 0 ? 0 : _a, _b = ref.b, b = _b === void 0 ? a : _b; +function test0() { + var ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { + }, _a = ref.a, a = _a === void 0 ? 0 : _a, _b = ref.b, b = _b === void 0 ? a : _b; return { a: a, b: b }; } -function test1(param) { - var ref = param === void 0 ? { - } : param, tmp = ref.c, ref1 = tmp === void 0 ? { +function test1() { + var ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { + }, tmp = ref.c, ref1 = tmp === void 0 ? { } : tmp, _a = ref1.a, a = _a === void 0 ? 0 : _a, _b = ref1.b, b = _b === void 0 ? a : _b; return { a: a, diff --git a/crates/swc/tests/tsc-references/functions/parameterInitializersForwardReferencing.2/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/functions/parameterInitializersForwardReferencing.2/input.ts/es5.1.normal/output.js index 3349051a8f7a3..08ea021bf43bc 100644 --- a/crates/swc/tests/tsc-references/functions/parameterInitializersForwardReferencing.2/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/functions/parameterInitializersForwardReferencing.2/input.ts/es5.1.normal/output.js @@ -34,16 +34,16 @@ function _objectWithoutPropertiesLoose(source, excluded) { // https://github.com/microsoft/TypeScript/issues/36295 function a() { } -function b(param) { - var _param = param === void 0 ? a() : param; +function b() { + var _param = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : a(); var _b = _param.b, b = _b === void 0 ? a() : _b, x = _objectWithoutProperties(_param, [ "b" ]); var a1; } var x = ""; -function c(param, param1) { - var _param = param === void 0 ? a() : param, d = param1 === void 0 ? x : param1; +function c() { + var _param = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : a(), d = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : x; var b = _param.b, c = _objectWithoutProperties(_param, [ "b" ]); diff --git a/crates/swc/tests/tsc-references/functions/parameterInitializersForwardReferencing/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/functions/parameterInitializersForwardReferencing/input.ts/es5.1.normal/output.js index 56d177e1494e0..d6725bd67466e 100644 --- a/crates/swc/tests/tsc-references/functions/parameterInitializersForwardReferencing/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/functions/parameterInitializersForwardReferencing/input.ts/es5.1.normal/output.js @@ -17,69 +17,69 @@ function _createClass(Constructor, protoProps, staticProps) { if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } -function left(a, param, param1) { - var b = param === void 0 ? a : param, c = param1 === void 0 ? b : param1; +function left(a) { + var b = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : a, c = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : b; a; b; } -function right(param, param2) { - var a = param === void 0 ? b : param, b1 = param2 === void 0 ? a : param2; +function right() { + var a = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : b, b1 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : a; a; b1; } -function right2(param, param3, param4) { - var a = param === void 0 ? b : param, b2 = param3 === void 0 ? c : param3, c1 = param4 === void 0 ? a : param4; +function right2() { + var a = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : b, b2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : c, c1 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : a; a; b2; c1; } -function inside(param) { - var a = param === void 0 ? b : param; +function inside() { + var a = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : b; var b3; } function outside() { - var inside = function inside(param) { - var a = param === void 0 ? b : param; + var inside = function inside() { + var a = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : b; var b4; }; var b; } -function defaultArgFunction(param, param5) { - var a = param === void 0 ? function() { +function defaultArgFunction() { + var a = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function() { return b; - } : param, b5 = param5 === void 0 ? 1 : param5; + }, b5 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1; } -function defaultArgArrow(param, param6) { - var a = param === void 0 ? function() { +function defaultArgArrow() { + var a = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function() { return function() { return b; }; - } : param, b6 = param6 === void 0 ? 3 : param6; + }, b6 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 3; } var C = /*#__PURE__*/ function() { "use strict"; - function C(param, param7) { - var a = param === void 0 ? b : param, b7 = param7 === void 0 ? 1 : param7; + function C() { + var a = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : b, b7 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1; _classCallCheck(this, C); } _createClass(C, [ { key: "method", - value: function method(param, param8) { - var a = param === void 0 ? b : param, b8 = param8 === void 0 ? 1 : param8; + value: function method() { + var a = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : b, b8 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1; } } ]); return C; }(); // Function expressions -var x = function(param, param9, param10) { - var a = param === void 0 ? b : param, b9 = param9 === void 0 ? c : param9, c2 = param10 === void 0 ? d : param10; +var x = function() { + var a = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : b, b9 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : c, c2 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : d; var d1; }; // Should not produce errors - can reference later parameters if they occur within a function expression initializer. -function f(a, param, param11) { - var b = param === void 0 ? function() { +function f(a) { + var b = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : function() { return c; - } : param, c3 = param11 === void 0 ? b() : param11; + }, c3 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : b(); } diff --git a/crates/swc/tests/tsc-references/functions/parameterInitializersForwardReferencing/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/functions/parameterInitializersForwardReferencing/input.ts/es5.2.minified/output.js index aec5f29fd9320..624db5614dc7e 100644 --- a/crates/swc/tests/tsc-references/functions/parameterInitializersForwardReferencing/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/functions/parameterInitializersForwardReferencing/input.ts/es5.2.minified/output.js @@ -7,15 +7,16 @@ function _defineProperties(target, props) { var C = function() { "use strict"; var Constructor, protoProps, staticProps; - function C(param, param1) { - !function(instance, Constructor) { + function C() { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0], arguments.length > 1 && void 0 !== arguments[1] && arguments[1], (function(instance, Constructor) { if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function"); - }(this, C); + })(this, C); } return Constructor = C, protoProps = [ { key: "method", - value: function(param, param2) { + value: function() { + arguments.length > 0 && void 0 !== arguments[0] && arguments[0], arguments.length > 1 && void 0 !== arguments[1] && arguments[1]; } } ], _defineProperties(Constructor.prototype, protoProps), staticProps && _defineProperties(Constructor, staticProps), C; diff --git a/crates/swc/tests/tsc-references/functions/parameterInitializersForwardReferencing1/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/functions/parameterInitializersForwardReferencing1/input.ts/es5.1.normal/output.js index c013b98fa9c80..fa8108ba194e5 100644 --- a/crates/swc/tests/tsc-references/functions/parameterInitializersForwardReferencing1/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/functions/parameterInitializersForwardReferencing1/input.ts/es5.1.normal/output.js @@ -4,46 +4,46 @@ function _classCallCheck(instance, Constructor) { } } var foo4 = ""; -function f1(param) { - var bar = param === void 0 ? foo4 : param; +function f1() { + var bar = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : foo4; var foo1 = 2; return bar; // returns 1 } -function f2(param1) { - var bar = param1 === void 0 ? function(param) { - var baz = param === void 0 ? foo4 : param; +function f2() { + var bar = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function() { + var baz = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : foo4; return baz; - } : param1; + }; var foo2 = 2; return bar(); // returns 1 } -function f3(param, param2) { - var bar = param === void 0 ? foo4 : param, foo3 = param2 === void 0 ? 2 : param2; +function f3() { + var bar = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : foo4, foo3 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 2; return bar; } -function f4(foo, param) { - var bar = param === void 0 ? foo : param; +function f4(foo) { + var bar = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : foo; return bar; } -function f5(param) { - var a = param === void 0 ? a : param; +function f5() { + var a = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : a; return a; } -function f6(param) { - var async = param === void 0 ? async : param; +function f6() { + var async = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : async; return async; } function f7(param) { var bar = param[foo4]; var foo = 2; } -var Foo = function Foo(param, param3) { +var Foo = function Foo() { "use strict"; - var x = param === void 0 ? 12 : param, y = param3 === void 0 ? x : param3; + var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 12, y = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : x; _classCallCheck(this, Foo); this.x = x; this.y = y; }; -function f8(foo1, param) { - var bar = param === void 0 ? foo1 : param; +function f8(foo1) { + var bar = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : foo1; } diff --git a/crates/swc/tests/tsc-references/functions/parameterInitializersForwardReferencing1/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/functions/parameterInitializersForwardReferencing1/input.ts/es5.2.minified/output.js index 83f1045380650..3f22b403d14df 100644 --- a/crates/swc/tests/tsc-references/functions/parameterInitializersForwardReferencing1/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/functions/parameterInitializersForwardReferencing1/input.ts/es5.2.minified/output.js @@ -1,7 +1,7 @@ -var Foo = function(param, param1) { +var Foo = function() { "use strict"; - var x = void 0 === param ? 12 : param; + var x = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 12, y = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : x; !function(instance, Constructor) { if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function"); - }(this, Foo), this.x = x, this.y = void 0 === param1 ? x : param1; + }(this, Foo), this.x = x, this.y = y; }; diff --git a/crates/swc/tests/tsc-references/functions/parameterInitializersForwardReferencing1_es6/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/functions/parameterInitializersForwardReferencing1_es6/input.ts/es5.1.normal/output.js index 1bd64fe2823ee..60626ee9dc988 100644 --- a/crates/swc/tests/tsc-references/functions/parameterInitializersForwardReferencing1_es6/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/functions/parameterInitializersForwardReferencing1_es6/input.ts/es5.1.normal/output.js @@ -5,46 +5,46 @@ function _classCallCheck(instance, Constructor) { } // @target: es2015 var foo4 = ""; -function f1(param) { - var bar = param === void 0 ? foo4 : param; +function f1() { + var bar = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : foo4; var foo1 = 2; return bar; // returns 1 } -function f2(param1) { - var bar = param1 === void 0 ? function(param) { - var baz = param === void 0 ? foo4 : param; +function f2() { + var bar = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function() { + var baz = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : foo4; return baz; - } : param1; + }; var foo2 = 2; return bar(); // returns 1 } -function f3(param, param2) { - var bar = param === void 0 ? foo4 : param, foo3 = param2 === void 0 ? 2 : param2; +function f3() { + var bar = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : foo4, foo3 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 2; return bar; } -function f4(foo, param) { - var bar = param === void 0 ? foo : param; +function f4(foo) { + var bar = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : foo; return bar; } -function f5(param) { - var a = param === void 0 ? a : param; +function f5() { + var a = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : a; return a; } -function f6(param) { - var async = param === void 0 ? async : param; +function f6() { + var async = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : async; return async; } function f7(param) { var bar = param[foo4]; var foo = 2; } -var Foo = function Foo(param, param3) { +var Foo = function Foo() { "use strict"; - var x = param === void 0 ? 12 : param, y = param3 === void 0 ? x : param3; + var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 12, y = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : x; _classCallCheck(this, Foo); this.x = x; this.y = y; }; -function f8(foo1, param) { - var bar = param === void 0 ? foo1 : param; +function f8(foo1) { + var bar = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : foo1; } diff --git a/crates/swc/tests/tsc-references/functions/parameterInitializersForwardReferencing1_es6/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/functions/parameterInitializersForwardReferencing1_es6/input.ts/es5.2.minified/output.js index 83f1045380650..3f22b403d14df 100644 --- a/crates/swc/tests/tsc-references/functions/parameterInitializersForwardReferencing1_es6/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/functions/parameterInitializersForwardReferencing1_es6/input.ts/es5.2.minified/output.js @@ -1,7 +1,7 @@ -var Foo = function(param, param1) { +var Foo = function() { "use strict"; - var x = void 0 === param ? 12 : param; + var x = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 12, y = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : x; !function(instance, Constructor) { if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function"); - }(this, Foo), this.x = x, this.y = void 0 === param1 ? x : param1; + }(this, Foo), this.x = x, this.y = y; }; diff --git a/crates/swc/tests/tsc-references/parser/ecmascript5/Generics/parserCastVersusArrowFunction1/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/parser/ecmascript5/Generics/parserCastVersusArrowFunction1/input.ts/es5.1.normal/output.js index f12ce429af648..170d64b0ca63a 100644 --- a/crates/swc/tests/tsc-references/parser/ecmascript5/Generics/parserCastVersusArrowFunction1/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/parser/ecmascript5/Generics/parserCastVersusArrowFunction1/input.ts/es5.1.normal/output.js @@ -8,8 +8,8 @@ var v = function(a) { var v = function(a, b) { return 1; }; -var v = function(param, param1) { - var a = param === void 0 ? 1 : param, b = param1 === void 0 ? 2 : param1; +var v = function() { + var a = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 1, b = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 2; return 1; }; var v = a; diff --git a/crates/swc/tests/tsc-references/parser/ecmascript5/parserRealSource12/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/parser/ecmascript5/parserRealSource12/input.ts/es5.1.normal/output.js index 99ca6c7b7aa4c..b2f6fe778dd42 100644 --- a/crates/swc/tests/tsc-references/parser/ecmascript5/parserRealSource12/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/parser/ecmascript5/parserRealSource12/input.ts/es5.1.normal/output.js @@ -40,8 +40,8 @@ var TypeScript1; _createClass(AstWalkOptions, [ { key: "stopWalk", - value: function stopWalk(param) { - var stop = param === void 0 ? true : param; + value: function stopWalk() { + var stop = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true; this.goChildren = !stop; this.goNextSibling = !stop; } diff --git a/crates/swc/tests/tsc-references/parser/ecmascript5/parserRealSource12/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/parser/ecmascript5/parserRealSource12/input.ts/es5.2.minified/output.js index a1b89a6ff7933..ac7e8fe4f3321 100644 --- a/crates/swc/tests/tsc-references/parser/ecmascript5/parserRealSource12/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/parser/ecmascript5/parserRealSource12/input.ts/es5.2.minified/output.js @@ -22,8 +22,8 @@ function _createClass(Constructor, protoProps, staticProps) { return _createClass(AstWalkOptions, [ { key: "stopWalk", - value: function(param) { - var stop = void 0 === param || param; + value: function() { + var stop = !(arguments.length > 0) || void 0 === arguments[0] || arguments[0]; this.goChildren = !stop, this.goNextSibling = !stop; } } diff --git a/crates/swc/tests/tsc-references/parser/ecmascript5/parserRealSource14/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/parser/ecmascript5/parserRealSource14/input.ts/es5.1.normal/output.js index ec635e2eaf470..2929632a238a5 100644 --- a/crates/swc/tests/tsc-references/parser/ecmascript5/parserRealSource14/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/parser/ecmascript5/parserRealSource14/input.ts/es5.1.normal/output.js @@ -36,8 +36,8 @@ var TypeScript; if (ast.minChar === -1 || ast.limChar === -1) return false; return true; }; - var getAstPathToPosition = function getAstPathToPosition(script, pos, param) { - var options = param === void 0 ? GetAstPathOptions1.Default : param; + var getAstPathToPosition = function getAstPathToPosition(script, pos) { + var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : GetAstPathOptions1.Default; var lookInComments = function(comments) { if (comments && comments.length > 0) { for(var i = 0; i < comments.length; i++){ diff --git a/crates/swc/tests/tsc-references/parser/ecmascript5/parserRealSource14/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/parser/ecmascript5/parserRealSource14/input.ts/es5.2.minified/output.js index 69966d45cb375..f2f331b8361ab 100644 --- a/crates/swc/tests/tsc-references/parser/ecmascript5/parserRealSource14/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/parser/ecmascript5/parserRealSource14/input.ts/es5.2.minified/output.js @@ -15,8 +15,8 @@ function _defineProperties(target, props) { return a >= b ? a : b; }, isValidAstNode = function(ast) { return null !== ast && -1 !== ast.minChar && -1 !== ast.limChar; - }, getAstPathToPosition = function(script, pos, param) { - var options = void 0 === param ? GetAstPathOptions.Default : param, lookInComments = function(comments) { + }, getAstPathToPosition = function(script, pos) { + var options = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : GetAstPathOptions.Default, lookInComments = function(comments) { if (comments && comments.length > 0) for(var i = 0; i < comments.length; i++){ var minChar = comments[i].minChar, limChar = comments[i].limChar; !comments[i].isBlockComment && limChar++, pos >= minChar && pos < limChar && ctx.path.push(comments[i]); diff --git a/crates/swc/tests/tsc-references/salsa/typeFromJSInitializer/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/salsa/typeFromJSInitializer/input.ts/es5.1.normal/output.js index 53d5214778d05..f2473bc925c05 100644 --- a/crates/swc/tests/tsc-references/salsa/typeFromJSInitializer/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/salsa/typeFromJSInitializer/input.ts/es5.1.normal/output.js @@ -28,8 +28,8 @@ a1.empty.push({ a1.empty.push('hi'); /** @type {number | undefined} */ var n; // should get any on parameter initialisers -function f(param, param1, param2) { - var a = param === void 0 ? null : param, b = param1 === void 0 ? n : param1, l = param2 === void 0 ? [] : param2; +function f() { + var a = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : null, b = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : n, l = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : []; // a should be any a = undefined; a = null; diff --git a/crates/swc/tests/tsc-references/types/literal/literalTypes2/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/types/literal/literalTypes2/input.ts/es5.1.normal/output.js index 0c4b43432b894..21a45ee4e76a5 100644 --- a/crates/swc/tests/tsc-references/types/literal/literalTypes2/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/types/literal/literalTypes2/input.ts/es5.1.normal/output.js @@ -25,8 +25,8 @@ var E1; })(E1 || (E1 = { })); var cond; -function f1(param, param1, param2, param3) { - var p1 = param === void 0 ? 1 : param, p2 = param1 === void 0 ? "abc" : param1, p3 = param2 === void 0 ? true : param2, p4 = param3 === void 0 ? E1.A : param3; +function f1() { + var p1 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 1, p2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "abc", p3 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true, p4 = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : E1.A; var v1 = 1; var v2 = -123; var v3 = 3 + 4; @@ -52,8 +52,8 @@ function f1(param, param1, param2, param3) { var c7 = true; var c8 = E1.A; } -function f2(param, param4, param5, param6) { - var p1 = param === void 0 ? 1 : param, p2 = param4 === void 0 ? "abc" : param4, p3 = param5 === void 0 ? true : param5, p4 = param6 === void 0 ? E1.A : param6; +function f2() { + var p1 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 1, p2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "abc", p3 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true, p4 = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : E1.A; var v1 = 1; var v2 = -123; var v3 = "abc"; diff --git a/crates/swc/tests/tsc-references/types/literal/literalTypesWidenInParameterPosition/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/types/literal/literalTypesWidenInParameterPosition/input.ts/es5.1.normal/output.js index 90cb5da31b668..7ed77028d6509 100644 --- a/crates/swc/tests/tsc-references/types/literal/literalTypesWidenInParameterPosition/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/types/literal/literalTypesWidenInParameterPosition/input.ts/es5.1.normal/output.js @@ -3,9 +3,9 @@ function _classCallCheck(instance, Constructor) { throw new TypeError("Cannot call a class as a function"); } } -var D = function D(param) { +var D = function D() { "use strict"; - var widen = param === void 0 ? 2 : param; + var widen = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 2; _classCallCheck(this, D); this.widen = widen; this.noWiden = 1; diff --git a/crates/swc/tests/tsc-references/types/literal/literalTypesWidenInParameterPosition/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/types/literal/literalTypesWidenInParameterPosition/input.ts/es5.2.minified/output.js index 394b411ac8293..b5c4831a9dae8 100644 --- a/crates/swc/tests/tsc-references/types/literal/literalTypesWidenInParameterPosition/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/types/literal/literalTypesWidenInParameterPosition/input.ts/es5.2.minified/output.js @@ -1,7 +1,8 @@ -var D = function(param) { +var D = function() { "use strict"; + var widen = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 2; !function(instance, Constructor) { if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function"); - }(this, D), this.widen = void 0 === param ? 2 : param, this.noWiden = 1, this.noWiden = 5, this.widen = 6; + }(this, D), this.widen = widen, this.noWiden = 1, this.noWiden = 5, this.widen = 6; }; new D(7); // ok diff --git a/crates/swc/tests/tsc-references/types/namedTypes/optionalMethods/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/types/namedTypes/optionalMethods/input.ts/es5.1.normal/output.js index aa87cc3b8747f..af3790d6611bb 100644 --- a/crates/swc/tests/tsc-references/types/namedTypes/optionalMethods/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/types/namedTypes/optionalMethods/input.ts/es5.1.normal/output.js @@ -94,8 +94,8 @@ function test1(x) { } var Bar = /*#__PURE__*/ function() { "use strict"; - function Bar(d, param) { - var e = param === void 0 ? 10 : param; + function Bar(d) { + var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 10; _classCallCheck(this, Bar); this.d = d; this.e = e; diff --git a/crates/swc/tests/tsc-references/types/namedTypes/optionalMethods/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/types/namedTypes/optionalMethods/input.ts/es5.2.minified/output.js index c0ad186ed9e5f..16dffee11df11 100644 --- a/crates/swc/tests/tsc-references/types/namedTypes/optionalMethods/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/types/namedTypes/optionalMethods/input.ts/es5.2.minified/output.js @@ -22,8 +22,9 @@ function _setPrototypeOf(o, p) { } var Bar = function() { "use strict"; - function Bar(d, param) { - _classCallCheck(this, Bar), this.d = d, this.e = void 0 === param ? 10 : param, this.c = 2; + function Bar(d) { + var e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 10; + _classCallCheck(this, Bar), this.d = d, this.e = e, this.c = 2; } return _createClass(Bar, [ { diff --git a/crates/swc/tests/tsc-references/types/rest/objectRestParameter/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/types/rest/objectRestParameter/input.ts/es5.1.normal/output.js index 1a21b39145193..cda936f68c2c0 100644 --- a/crates/swc/tests/tsc-references/types/rest/objectRestParameter/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/types/rest/objectRestParameter/input.ts/es5.1.normal/output.js @@ -59,14 +59,14 @@ suddenly(function(_param) { ]); return rest.y; }); -suddenly(function(param) { - var _param = param === void 0 ? { +suddenly(function() { + var _param = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { x: { z: 1, ka: 1 }, y: 'noo' - } : param; + }; var _x = _param.x, _z = _x.z, z = _z === void 0 ? 12 : _z, nested = _objectWithoutProperties(_param.x, [ "z" ]), rest = _objectWithoutProperties(_param, [ @@ -101,9 +101,9 @@ var C = /*#__PURE__*/ function() { ]); return C; }(); -function foobar(param) { - var _param = param === void 0 ? { - } : param; +function foobar() { + var _param = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { + }; var _bar = _param.bar, bar = _bar === void 0 ? { } : _bar, opts = _objectWithoutProperties(_param, [ "bar" diff --git a/crates/swc/tests/tsc-references/types/rest/objectRestParameter/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/types/rest/objectRestParameter/input.ts/es5.2.minified/output.js index cc5330b344c00..36fa98e8e6d24 100644 --- a/crates/swc/tests/tsc-references/types/rest/objectRestParameter/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/types/rest/objectRestParameter/input.ts/es5.2.minified/output.js @@ -26,14 +26,14 @@ suddenly(function(_param) { return _param.x, _objectWithoutProperties(_param, [ "x" ]).y; -}), suddenly(function(param) { - var _param = void 0 === param ? { +}), suddenly(function() { + var _param = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : { x: { z: 1, ka: 1 }, y: "noo" - } : param, _z = _param.x.z, nested = _objectWithoutProperties(_param.x, [ + }, _z = _param.x.z, nested = _objectWithoutProperties(_param.x, [ "z" ]), rest = _objectWithoutProperties(_param, [ "x" @@ -67,9 +67,9 @@ var C = function() { } ], _defineProperties(Constructor.prototype, protoProps), staticProps && _defineProperties(Constructor, staticProps), C; }(); -function foobar(param) { - var _param = void 0 === param ? { - } : param; +function foobar() { + var _param = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : { + }; _param.bar, _objectWithoutProperties(_param, [ "bar" ]); diff --git a/crates/swc/tests/tsc-references/types/rest/objectRestParameterES5/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/types/rest/objectRestParameterES5/input.ts/es5.1.normal/output.js index 40a1358dce0ee..adae7173e3348 100644 --- a/crates/swc/tests/tsc-references/types/rest/objectRestParameterES5/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/types/rest/objectRestParameterES5/input.ts/es5.1.normal/output.js @@ -59,14 +59,14 @@ suddenly(function(_param) { ]); return rest.y; }); -suddenly(function(param) { - var _param = param === void 0 ? { +suddenly(function() { + var _param = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { x: { z: 1, ka: 1 }, y: 'noo' - } : param; + }; var _x = _param.x, _z = _x.z, z = _z === void 0 ? 12 : _z, nested = _objectWithoutProperties(_param.x, [ "z" ]), rest = _objectWithoutProperties(_param, [ @@ -101,9 +101,9 @@ var C = /*#__PURE__*/ function() { ]); return C; }(); -function foobar(param) { - var _param = param === void 0 ? { - } : param; +function foobar() { + var _param = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { + }; var _bar = _param.bar, bar = _bar === void 0 ? { } : _bar, opts = _objectWithoutProperties(_param, [ "bar" diff --git a/crates/swc/tests/tsc-references/types/rest/objectRestParameterES5/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/types/rest/objectRestParameterES5/input.ts/es5.2.minified/output.js index cc5330b344c00..36fa98e8e6d24 100644 --- a/crates/swc/tests/tsc-references/types/rest/objectRestParameterES5/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/types/rest/objectRestParameterES5/input.ts/es5.2.minified/output.js @@ -26,14 +26,14 @@ suddenly(function(_param) { return _param.x, _objectWithoutProperties(_param, [ "x" ]).y; -}), suddenly(function(param) { - var _param = void 0 === param ? { +}), suddenly(function() { + var _param = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : { x: { z: 1, ka: 1 }, y: "noo" - } : param, _z = _param.x.z, nested = _objectWithoutProperties(_param.x, [ + }, _z = _param.x.z, nested = _objectWithoutProperties(_param.x, [ "z" ]), rest = _objectWithoutProperties(_param, [ "x" @@ -67,9 +67,9 @@ var C = function() { } ], _defineProperties(Constructor.prototype, protoProps), staticProps && _defineProperties(Constructor, staticProps), C; }(); -function foobar(param) { - var _param = void 0 === param ? { - } : param; +function foobar() { + var _param = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : { + }; _param.bar, _objectWithoutProperties(_param, [ "bar" ]); diff --git a/crates/swc/tests/tsc-references/types/tuple/tupleElementTypes4/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/types/tuple/tupleElementTypes4/input.ts/es5.1.normal/output.js index 4219a441d17f9..89d2cc3e01fff 100644 --- a/crates/swc/tests/tsc-references/types/tuple/tupleElementTypes4/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/types/tuple/tupleElementTypes4/input.ts/es5.1.normal/output.js @@ -29,9 +29,9 @@ function _nonIterableRest() { function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } -function f(param) { - var ref = _slicedToArray(param === void 0 ? [ +function f() { + var ref = _slicedToArray(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [ 0, undefined - ] : param, 2), a = ref[0], b = ref[1]; + ], 2), a = ref[0], b = ref[1]; } diff --git a/crates/swc/tests/tsc-references/types/typeRelationships/assignmentCompatibility/genericCallWithObjectTypeArgsAndInitializers/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/types/typeRelationships/assignmentCompatibility/genericCallWithObjectTypeArgsAndInitializers/input.ts/es5.1.normal/output.js index 02b7c8851f404..e2bab0c4e832f 100644 --- a/crates/swc/tests/tsc-references/types/typeRelationships/assignmentCompatibility/genericCallWithObjectTypeArgsAndInitializers/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/types/typeRelationships/assignmentCompatibility/genericCallWithObjectTypeArgsAndInitializers/input.ts/es5.1.normal/output.js @@ -1,24 +1,24 @@ // Generic typed parameters with initializers -function foo(param) { - var x = param === void 0 ? null : param; +function foo() { + var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : null; return x; } // ok -function foo2(param) { - var x = param === void 0 ? undefined : param; +function foo2() { + var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : undefined; return x; } // ok -function foo3(param) { - var x = param === void 0 ? 1 : param; +function foo3() { + var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 1; } // error -function foo4(x, param) { - var y = param === void 0 ? x : param; +function foo4(x) { + var y = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : x; } // error -function foo5(x, param) { - var y = param === void 0 ? x : param; +function foo5(x) { + var y = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : x; } // ok -function foo6(x, y, param) { - var z = param === void 0 ? y : param; +function foo6(x, y) { + var z = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : y; } // error -function foo7(x, param) { - var y = param === void 0 ? x : param; +function foo7(x) { + var y = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : x; } // should be ok diff --git a/crates/swc/tests/tsc-references/types/typeRelationships/recursiveTypes/recursiveTypeReferences1/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/types/typeRelationships/recursiveTypes/recursiveTypeReferences1/input.ts/es5.1.normal/output.js index 7e23caefc2a68..7052c34b0fcaf 100644 --- a/crates/swc/tests/tsc-references/types/typeRelationships/recursiveTypes/recursiveTypeReferences1/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/types/typeRelationships/recursiveTypes/recursiveTypeReferences1/input.ts/es5.1.normal/output.js @@ -262,8 +262,8 @@ flat2([ ]); // Error var x1 = foo1(ra1); // Boom! var x2 = foo2(ra2); // Boom! -function parse(node, param1) { - var index = param1 === void 0 ? [] : param1; +function parse(node) { + var index = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : []; return html('ul', node.map(function(param, i) { var _param = _slicedToArray(param, 2), el = _param[0], children = _param[1]; var idx = _toConsumableArray(index).concat([ diff --git a/crates/swc/tests/tsc-references/types/uniqueSymbol/uniqueSymbols/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/types/uniqueSymbol/uniqueSymbols/input.ts/es5.1.normal/output.js index 20616ad0ad745..86881e373c4ba 100644 --- a/crates/swc/tests/tsc-references/types/uniqueSymbol/uniqueSymbols/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/types/uniqueSymbol/uniqueSymbols/input.ts/es5.1.normal/output.js @@ -453,8 +453,8 @@ var o2 = { } }, _callee); }), - method5: function(param) { - var p = param === void 0 ? s : param; + method5: function() { + var p = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : s; return p; } }; @@ -527,8 +527,8 @@ var C0 = // property initializers }, { key: "method5", - value: function method5(param) { - var p = param === void 0 ? s : param; + value: function method5() { + var p = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : s; return p; } } @@ -612,8 +612,8 @@ var o3 = { } }, _callee); }), - method5: function(param) { - var p = param === void 0 ? s : param; + method5: function() { + var p = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : s; return p; } }; diff --git a/crates/swc/tests/tsc-references/types/uniqueSymbol/uniqueSymbols/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/types/uniqueSymbol/uniqueSymbols/input.ts/es5.2.minified/output.js index a20b96ac8f93c..526fc07d86e62 100644 --- a/crates/swc/tests/tsc-references/types/uniqueSymbol/uniqueSymbols/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/types/uniqueSymbol/uniqueSymbols/input.ts/es5.2.minified/output.js @@ -306,8 +306,9 @@ var C0 = function() { }, { key: "method5", - value: function(param) { - return void 0 === param ? s : param; + value: function() { + var p = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : s; + return p; } } ]), C0; diff --git a/crates/swc/tests/tsc-references/types/uniqueSymbol/uniqueSymbolsDeclarations/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/types/uniqueSymbol/uniqueSymbolsDeclarations/input.ts/es5.1.normal/output.js index 99fe894713ddd..fbda964c48c1c 100644 --- a/crates/swc/tests/tsc-references/types/uniqueSymbol/uniqueSymbolsDeclarations/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/types/uniqueSymbol/uniqueSymbolsDeclarations/input.ts/es5.1.normal/output.js @@ -449,8 +449,8 @@ var o2 = { } }, _callee); }), - method5: function(param) { - var p = param === void 0 ? s : param; + method5: function() { + var p = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : s; return p; } }; @@ -523,8 +523,8 @@ var C0 = // property initializers }, { key: "method5", - value: function method5(param) { - var p = param === void 0 ? s : param; + value: function method5() { + var p = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : s; return p; } } @@ -608,8 +608,8 @@ var o4 = { } }, _callee); }), - method5: function(param) { - var p = param === void 0 ? s : param; + method5: function() { + var p = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : s; return p; } }; diff --git a/crates/swc/tests/tsc-references/types/uniqueSymbol/uniqueSymbolsDeclarations/input.ts/es5.2.minified/output.js b/crates/swc/tests/tsc-references/types/uniqueSymbol/uniqueSymbolsDeclarations/input.ts/es5.2.minified/output.js index 7cfef4eb06458..ce972d96fba0a 100644 --- a/crates/swc/tests/tsc-references/types/uniqueSymbol/uniqueSymbolsDeclarations/input.ts/es5.2.minified/output.js +++ b/crates/swc/tests/tsc-references/types/uniqueSymbol/uniqueSymbolsDeclarations/input.ts/es5.2.minified/output.js @@ -304,8 +304,9 @@ var C0 = function() { }, { key: "method5", - value: function(param) { - return void 0 === param ? s : param; + value: function() { + var p = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : s; + return p; } } ], _defineProperties(Constructor.prototype, protoProps), staticProps && _defineProperties(Constructor, staticProps), C0; diff --git a/crates/swc/tests/tsc-references/types/witness/witness/input.ts/es5.1.normal/output.js b/crates/swc/tests/tsc-references/types/witness/witness/input.ts/es5.1.normal/output.js index 07dac2f56d886..173176c58b14a 100644 --- a/crates/swc/tests/tsc-references/types/witness/witness/input.ts/es5.1.normal/output.js +++ b/crates/swc/tests/tsc-references/types/witness/witness/input.ts/es5.1.normal/output.js @@ -20,8 +20,8 @@ function _createClass(Constructor, protoProps, staticProps) { // Initializers var varInit = varInit; // any var pInit1; -function fn(param) { - var pInit = param === void 0 ? pInit : param; +function fn() { + var pInit = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : pInit; var pInit; } var InitClass = /*#__PURE__*/ function() { diff --git a/crates/swc_ecma_transforms_compat/tests/es2015_destructuring.rs b/crates/swc_ecma_transforms_compat/tests/es2015_destructuring.rs index 8db8cfa291f30..7ef731317c2e4 100644 --- a/crates/swc_ecma_transforms_compat/tests/es2015_destructuring.rs +++ b/crates/swc_ecma_transforms_compat/tests/es2015_destructuring.rs @@ -1553,7 +1553,7 @@ test!( spread(spread::Config { ..Default::default() }), - parameters(), + parameters(Default::default()), destructuring(Config { loose: true }), block_scoping(), object_rest_spread(Default::default()),