diff --git a/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter_es2015.2.minified.js b/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter_es2015.2.minified.js index d215bd1206b..19288b7123a 100644 --- a/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter_es2015.2.minified.js @@ -1,5 +1,14 @@ +class clodule1 { +} +clodule1 || (clodule1 = {}); +class clodule2 { +} +clodule2 || (clodule2 = {}); class clodule3 { } (clodule3 || (clodule3 = {})).y = { id: T }; +class clodule4 { +} +clodule4 || (clodule4 = {}); diff --git a/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter_es5.2.minified.js b/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter_es5.2.minified.js index 5a6c9f39a33..9a0e8b894cd 100644 --- a/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter_es5.2.minified.js @@ -2,7 +2,9 @@ import * as swcHelpers from "@swc/helpers"; var clodule1 = function() { "use strict"; swcHelpers.classCallCheck(this, clodule1); -}, clodule2 = function() { +}; +clodule1 || (clodule1 = {}); +var clodule2 = function() { "use strict"; swcHelpers.classCallCheck(this, clodule2); }; diff --git a/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName_es2015.2.minified.js b/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName_es2015.2.minified.js index 1a7f50b9560..4901910efca 100644 --- a/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName_es2015.2.minified.js @@ -1,5 +1,5 @@ var A; -(A || (A = {})).Point = class { +class Point { static Origin() { return { x: 0, @@ -9,4 +9,18 @@ var A; constructor(x, y){ this.x = x, this.y = y; } -}; +} +Point || (Point = {}), function(A1) { + class Point1 { + static Origin() { + return { + x: 0, + y: 0 + }; + } + constructor(x, y){ + this.x = x, this.y = y; + } + } + A1.Point = Point1, Point1 = A1.Point || (A1.Point = {}); +}(A || (A = {})); diff --git a/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName_es5.2.minified.js b/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName_es5.2.minified.js index 01c5364917d..4425df8d7e9 100644 --- a/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName_es5.2.minified.js @@ -11,7 +11,7 @@ var A, Point = function() { }; }, Point; }(); -!function(A1) { +Point || (Point = {}), function(A1) { var Point = function() { "use strict"; function Point(x, y) { @@ -24,5 +24,5 @@ var A, Point = function() { }; }, Point; }(); - A1.Point = Point; + A1.Point = Point, Point = A1.Point || (A1.Point = {}); }(A || (A = {})); diff --git a/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName_es2015.2.minified.js b/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName_es2015.2.minified.js index f39dc1ff149..2501a181e9a 100644 --- a/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName_es2015.2.minified.js @@ -1,19 +1,20 @@ var A; -(class { +class Point { constructor(x, y){ this.x = x, this.y = y; } -}).Origin = { +} +Point.Origin = { x: 0, y: 0 -}, function(A1) { - class Point { +}, Point || (Point = {}), function(A1) { + class Point1 { constructor(x, y){ this.x = x, this.y = y; } } - Point.Origin = { + Point1.Origin = { x: 0, y: 0 - }, A1.Point = Point; + }, A1.Point = Point1, Point1 = A1.Point || (A1.Point = {}); }(A || (A = {})); diff --git a/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName_es5.2.minified.js b/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName_es5.2.minified.js index 255ccacfd94..a41ded006be 100644 --- a/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName_es5.2.minified.js @@ -6,7 +6,7 @@ var A, Point = function(x, y) { Point.Origin = { x: 0, y: 0 -}, function(A1) { +}, Point || (Point = {}), function(A1) { var Point1 = function(x, y) { "use strict"; swcHelpers.classCallCheck(this, Point1), this.x = x, this.y = y; @@ -14,5 +14,5 @@ Point.Origin = { Point1.Origin = { x: 0, y: 0 - }, A1.Point = Point1; + }, A1.Point = Point1, Point1 = A1.Point || (A1.Point = {}); }(A || (A = {})); diff --git a/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedAndNonExportedClassesOfTheSameName_es2015.2.minified.js b/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedAndNonExportedClassesOfTheSameName_es2015.2.minified.js index 0a322c1b3b1..0bc99fcee1e 100644 --- a/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedAndNonExportedClassesOfTheSameName_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedAndNonExportedClassesOfTheSameName_es2015.2.minified.js @@ -1,9 +1,10 @@ var A, X; (A || (A = {})).Point = class { -}, function(X1) { +}, A || (A = {}), function(X1) { var Y; ((Y = X1.Y || (X1.Y = {})).Z || (Y.Z = {})).Line = class { }; }(X || (X = {})), function(X2) { - X2.Y || (X2.Y = {}); + var Y; + (Y = X2.Y || (X2.Y = {})).Z || (Y.Z = {}); }(X || (X = {})); diff --git a/crates/swc/tests/tsc-references/ambientInsideNonAmbient_es2015.2.minified.js b/crates/swc/tests/tsc-references/ambientInsideNonAmbient_es2015.2.minified.js new file mode 100644 index 00000000000..9f5382a78bb --- /dev/null +++ b/crates/swc/tests/tsc-references/ambientInsideNonAmbient_es2015.2.minified.js @@ -0,0 +1,5 @@ +var M2; +!function(M2) { + let E; + E || (E = {}); +}(M2 || (M2 = {})); diff --git a/crates/swc/tests/tsc-references/ambientInsideNonAmbient_es5.2.minified.js b/crates/swc/tests/tsc-references/ambientInsideNonAmbient_es5.2.minified.js new file mode 100644 index 00000000000..185c784ec0a --- /dev/null +++ b/crates/swc/tests/tsc-references/ambientInsideNonAmbient_es5.2.minified.js @@ -0,0 +1,5 @@ +var M2; +!function(M2) { + var E; + E || (E = {}); +}(M2 || (M2 = {})); diff --git a/crates/swc/tests/tsc-references/annotatedThisPropertyInitializerDoesntNarrow_es2015.2.minified.js b/crates/swc/tests/tsc-references/annotatedThisPropertyInitializerDoesntNarrow_es2015.2.minified.js index c3007a3550c..f55a3c66e21 100644 --- a/crates/swc/tests/tsc-references/annotatedThisPropertyInitializerDoesntNarrow_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/annotatedThisPropertyInitializerDoesntNarrow_es2015.2.minified.js @@ -1,5 +1,7 @@ export class C { - m() {} + m() { + this.assets; + } constructor(){ this.assets = {}; } diff --git a/crates/swc/tests/tsc-references/annotatedThisPropertyInitializerDoesntNarrow_es5.2.minified.js b/crates/swc/tests/tsc-references/annotatedThisPropertyInitializerDoesntNarrow_es5.2.minified.js index df9edf8f7cc..5851ccddf8d 100644 --- a/crates/swc/tests/tsc-references/annotatedThisPropertyInitializerDoesntNarrow_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/annotatedThisPropertyInitializerDoesntNarrow_es5.2.minified.js @@ -4,5 +4,7 @@ export var C = function() { function C() { swcHelpers.classCallCheck(this, C), this.assets = {}; } - return C.prototype.m = function() {}, C; + return C.prototype.m = function() { + this.assets; + }, C; }(); diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithDiscriminatedUnion_es2015.2.minified.js b/crates/swc/tests/tsc-references/assignmentCompatWithDiscriminatedUnion_es2015.2.minified.js index 03fadc0e092..607012fdbc3 100644 --- a/crates/swc/tests/tsc-references/assignmentCompatWithDiscriminatedUnion_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/assignmentCompatWithDiscriminatedUnion_es2015.2.minified.js @@ -1,13 +1,13 @@ -var Example1, Example2, Example3, Example4, Example5, GH14865, GH12052; +var Example1, Example2, Example3, Example4, Example5, GH14865, GH30170, GH12052, GH18421, GH15907, GH20889, GH39357; Example1 || (Example1 = {}), t = s, Example2 || (Example2 = {}), t = s, Example3 || (Example3 = {}), t = s, Example4 || (Example4 = {}), t = s, Example5 || (Example5 = {}), t = s, function(GH14865) { let b; b.type, b = { type: "A", data: "whatevs" }; -}(GH14865 || (GH14865 = {})), function(GH12052) { +}(GH14865 || (GH14865 = {})), GH30170 || (GH30170 = {}), function(GH12052) { let good = { type: void 0 }; good.type = "categorical"; -}(GH12052 || (GH12052 = {})); +}(GH12052 || (GH12052 = {})), GH18421 || (GH18421 = {}), GH15907 || (GH15907 = {}), GH20889 || (GH20889 = {}), GH39357 || (GH39357 = {}); diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithDiscriminatedUnion_es5.2.minified.js b/crates/swc/tests/tsc-references/assignmentCompatWithDiscriminatedUnion_es5.2.minified.js index edcdcb3cda0..7916b1597cf 100644 --- a/crates/swc/tests/tsc-references/assignmentCompatWithDiscriminatedUnion_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/assignmentCompatWithDiscriminatedUnion_es5.2.minified.js @@ -1,13 +1,13 @@ -var Example1, Example2, Example3, Example4, Example5, GH14865, GH12052; +var Example1, Example2, Example3, Example4, Example5, GH14865, GH30170, GH12052, GH18421, GH15907, GH20889, GH39357; Example1 || (Example1 = {}), t = s, Example2 || (Example2 = {}), t = s, Example3 || (Example3 = {}), t = s, Example4 || (Example4 = {}), t = s, Example5 || (Example5 = {}), t = s, function(GH14865) { var b; b.type, b = { type: "A", data: "whatevs" }; -}(GH14865 || (GH14865 = {})), function(GH12052) { +}(GH14865 || (GH14865 = {})), GH30170 || (GH30170 = {}), function(GH12052) { var getAxisType = function() { return "categorical"; }; getAxisType(), void 0 = getAxisType(); -}(GH12052 || (GH12052 = {})); +}(GH12052 || (GH12052 = {})), GH18421 || (GH18421 = {}), GH15907 || (GH15907 = {}), GH20889 || (GH20889 = {}), GH39357 || (GH39357 = {}); diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithGenericCallSignaturesWithOptionalParameters_es2015.2.minified.js b/crates/swc/tests/tsc-references/assignmentCompatWithGenericCallSignaturesWithOptionalParameters_es2015.2.minified.js new file mode 100644 index 00000000000..7c227461184 --- /dev/null +++ b/crates/swc/tests/tsc-references/assignmentCompatWithGenericCallSignaturesWithOptionalParameters_es2015.2.minified.js @@ -0,0 +1,2 @@ +var ClassTypeParam, GenericSignaturesInvalid, GenericSignaturesValid; +ClassTypeParam || (ClassTypeParam = {}), GenericSignaturesInvalid || (GenericSignaturesInvalid = {}), GenericSignaturesValid || (GenericSignaturesValid = {}); diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithNumericIndexer2_es2015.2.minified.js b/crates/swc/tests/tsc-references/assignmentCompatWithNumericIndexer2_es2015.2.minified.js new file mode 100644 index 00000000000..4558588552f --- /dev/null +++ b/crates/swc/tests/tsc-references/assignmentCompatWithNumericIndexer2_es2015.2.minified.js @@ -0,0 +1,2 @@ +var Generics; +Generics || (Generics = {}); diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithNumericIndexer2_es5.2.minified.js b/crates/swc/tests/tsc-references/assignmentCompatWithNumericIndexer2_es5.2.minified.js new file mode 100644 index 00000000000..4558588552f --- /dev/null +++ b/crates/swc/tests/tsc-references/assignmentCompatWithNumericIndexer2_es5.2.minified.js @@ -0,0 +1,2 @@ +var Generics; +Generics || (Generics = {}); diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithNumericIndexer3_es2015.2.minified.js b/crates/swc/tests/tsc-references/assignmentCompatWithNumericIndexer3_es2015.2.minified.js new file mode 100644 index 00000000000..4558588552f --- /dev/null +++ b/crates/swc/tests/tsc-references/assignmentCompatWithNumericIndexer3_es2015.2.minified.js @@ -0,0 +1,2 @@ +var Generics; +Generics || (Generics = {}); diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithNumericIndexer_es2015.2.minified.js b/crates/swc/tests/tsc-references/assignmentCompatWithNumericIndexer_es2015.2.minified.js new file mode 100644 index 00000000000..4558588552f --- /dev/null +++ b/crates/swc/tests/tsc-references/assignmentCompatWithNumericIndexer_es2015.2.minified.js @@ -0,0 +1,2 @@ +var Generics; +Generics || (Generics = {}); diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithObjectMembersStringNumericNames_es2015.2.minified.js b/crates/swc/tests/tsc-references/assignmentCompatWithObjectMembersStringNumericNames_es2015.2.minified.js new file mode 100644 index 00000000000..948f4c20e5f --- /dev/null +++ b/crates/swc/tests/tsc-references/assignmentCompatWithObjectMembersStringNumericNames_es2015.2.minified.js @@ -0,0 +1,2 @@ +var JustStrings, NumbersAndStrings; +JustStrings || (JustStrings = {}), NumbersAndStrings || (NumbersAndStrings = {}); diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithObjectMembers_es2015.2.minified.js b/crates/swc/tests/tsc-references/assignmentCompatWithObjectMembers_es2015.2.minified.js index bc927b98bc8..286b11d9009 100644 --- a/crates/swc/tests/tsc-references/assignmentCompatWithObjectMembers_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/assignmentCompatWithObjectMembers_es2015.2.minified.js @@ -1,5 +1,5 @@ -var ObjectTypes; -!function(ObjectTypes) { +var SimpleTypes, ObjectTypes; +SimpleTypes || (SimpleTypes = {}), function(ObjectTypes) { var t, t2, b, a2 = { foo: a2 }, b2 = { diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithStringIndexer2_es2015.2.minified.js b/crates/swc/tests/tsc-references/assignmentCompatWithStringIndexer2_es2015.2.minified.js new file mode 100644 index 00000000000..4558588552f --- /dev/null +++ b/crates/swc/tests/tsc-references/assignmentCompatWithStringIndexer2_es2015.2.minified.js @@ -0,0 +1,2 @@ +var Generics; +Generics || (Generics = {}); diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithStringIndexer2_es5.2.minified.js b/crates/swc/tests/tsc-references/assignmentCompatWithStringIndexer2_es5.2.minified.js new file mode 100644 index 00000000000..4558588552f --- /dev/null +++ b/crates/swc/tests/tsc-references/assignmentCompatWithStringIndexer2_es5.2.minified.js @@ -0,0 +1,2 @@ +var Generics; +Generics || (Generics = {}); diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithStringIndexer3_es2015.2.minified.js b/crates/swc/tests/tsc-references/assignmentCompatWithStringIndexer3_es2015.2.minified.js new file mode 100644 index 00000000000..4558588552f --- /dev/null +++ b/crates/swc/tests/tsc-references/assignmentCompatWithStringIndexer3_es2015.2.minified.js @@ -0,0 +1,2 @@ +var Generics; +Generics || (Generics = {}); diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithStringIndexer_es2015.2.minified.js b/crates/swc/tests/tsc-references/assignmentCompatWithStringIndexer_es2015.2.minified.js new file mode 100644 index 00000000000..4558588552f --- /dev/null +++ b/crates/swc/tests/tsc-references/assignmentCompatWithStringIndexer_es2015.2.minified.js @@ -0,0 +1,2 @@ +var Generics; +Generics || (Generics = {}); diff --git a/crates/swc/tests/tsc-references/asyncArrowFunction_allowJs_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncArrowFunction_allowJs_es5.2.minified.js index e8abb3b5ea4..349013a8ec1 100644 --- a/crates/swc/tests/tsc-references/asyncArrowFunction_allowJs_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncArrowFunction_allowJs_es5.2.minified.js @@ -20,4 +20,14 @@ swcHelpers.asyncToGenerator(regeneratorRuntime.mark(function _callee() { return _ctx.stop(); } }, _callee); +})), swcHelpers.asyncToGenerator(regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function(_ctx) { + for(;;)switch(_ctx.prev = _ctx.next){ + case 0: + return _ctx.abrupt("return", 0); + case 1: + case "end": + return _ctx.stop(); + } + }, _callee); })); diff --git a/crates/swc/tests/tsc-references/callSignatureAssignabilityInInheritance3_es2015.2.minified.js b/crates/swc/tests/tsc-references/callSignatureAssignabilityInInheritance3_es2015.2.minified.js new file mode 100644 index 00000000000..d0629cd7061 --- /dev/null +++ b/crates/swc/tests/tsc-references/callSignatureAssignabilityInInheritance3_es2015.2.minified.js @@ -0,0 +1,2 @@ +var Errors; +Errors || (Errors = {}); diff --git a/crates/swc/tests/tsc-references/classAndInterfaceWithSameName_es2015.2.minified.js b/crates/swc/tests/tsc-references/classAndInterfaceWithSameName_es2015.2.minified.js new file mode 100644 index 00000000000..cf77a4b72fa --- /dev/null +++ b/crates/swc/tests/tsc-references/classAndInterfaceWithSameName_es2015.2.minified.js @@ -0,0 +1,2 @@ +var M; +M || (M = {}); diff --git a/crates/swc/tests/tsc-references/classAndVariableWithSameName_es2015.2.minified.js b/crates/swc/tests/tsc-references/classAndVariableWithSameName_es2015.2.minified.js new file mode 100644 index 00000000000..cf77a4b72fa --- /dev/null +++ b/crates/swc/tests/tsc-references/classAndVariableWithSameName_es2015.2.minified.js @@ -0,0 +1,2 @@ +var M; +M || (M = {}); diff --git a/crates/swc/tests/tsc-references/classExpression_es2015.2.minified.js b/crates/swc/tests/tsc-references/classExpression_es2015.2.minified.js new file mode 100644 index 00000000000..cf77a4b72fa --- /dev/null +++ b/crates/swc/tests/tsc-references/classExpression_es2015.2.minified.js @@ -0,0 +1,2 @@ +var M; +M || (M = {}); diff --git a/crates/swc/tests/tsc-references/classExpression_es5.2.minified.js b/crates/swc/tests/tsc-references/classExpression_es5.2.minified.js index a885268f673..eed3e240bca 100644 --- a/crates/swc/tests/tsc-references/classExpression_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/classExpression_es5.2.minified.js @@ -1 +1,3 @@ +var M; import * as swcHelpers from "@swc/helpers"; +M || (M = {}); diff --git a/crates/swc/tests/tsc-references/classExtendsShadowedConstructorFunction_es2015.2.minified.js b/crates/swc/tests/tsc-references/classExtendsShadowedConstructorFunction_es2015.2.minified.js new file mode 100644 index 00000000000..cf77a4b72fa --- /dev/null +++ b/crates/swc/tests/tsc-references/classExtendsShadowedConstructorFunction_es2015.2.minified.js @@ -0,0 +1,2 @@ +var M; +M || (M = {}); diff --git a/crates/swc/tests/tsc-references/constructSignatureAssignabilityInInheritance3_es2015.2.minified.js b/crates/swc/tests/tsc-references/constructSignatureAssignabilityInInheritance3_es2015.2.minified.js new file mode 100644 index 00000000000..d0629cd7061 --- /dev/null +++ b/crates/swc/tests/tsc-references/constructSignatureAssignabilityInInheritance3_es2015.2.minified.js @@ -0,0 +1,2 @@ +var Errors; +Errors || (Errors = {}); diff --git a/crates/swc/tests/tsc-references/duplicateStringIndexers_es2015.2.minified.js b/crates/swc/tests/tsc-references/duplicateStringIndexers_es2015.2.minified.js new file mode 100644 index 00000000000..b2031c45da6 --- /dev/null +++ b/crates/swc/tests/tsc-references/duplicateStringIndexers_es2015.2.minified.js @@ -0,0 +1,2 @@ +var test; +test || (test = {}); diff --git a/crates/swc/tests/tsc-references/enumAssignability_es2015.2.minified.js b/crates/swc/tests/tsc-references/enumAssignability_es2015.2.minified.js index 1da8430a6f1..2f523fa9fe9 100644 --- a/crates/swc/tests/tsc-references/enumAssignability_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/enumAssignability_es2015.2.minified.js @@ -1,6 +1,6 @@ -var E, F; +var E, F, Others; !function(E) { E[E.A = 0] = "A"; }(E || (E = {})), function(F) { F[F.B = 0] = "B"; -}(F || (F = {})), E.A, F.B; +}(F || (F = {})), E.A, F.B, Others || (Others = {}); diff --git a/crates/swc/tests/tsc-references/es6modulekindWithES5Target7_es2015.2.minified.js b/crates/swc/tests/tsc-references/es6modulekindWithES5Target7_es2015.2.minified.js index 26b040ffcd3..ab9feb11942 100644 --- a/crates/swc/tests/tsc-references/es6modulekindWithES5Target7_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/es6modulekindWithES5Target7_es2015.2.minified.js @@ -1 +1,2 @@ export var N; +N || (N = {}); diff --git a/crates/swc/tests/tsc-references/es6modulekindWithES5Target7_es5.2.minified.js b/crates/swc/tests/tsc-references/es6modulekindWithES5Target7_es5.2.minified.js index 26b040ffcd3..ab9feb11942 100644 --- a/crates/swc/tests/tsc-references/es6modulekindWithES5Target7_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/es6modulekindWithES5Target7_es5.2.minified.js @@ -1 +1,2 @@ export var N; +N || (N = {}); diff --git a/crates/swc/tests/tsc-references/esnextmodulekindWithES5Target7_es2015.2.minified.js b/crates/swc/tests/tsc-references/esnextmodulekindWithES5Target7_es2015.2.minified.js index 26b040ffcd3..ab9feb11942 100644 --- a/crates/swc/tests/tsc-references/esnextmodulekindWithES5Target7_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/esnextmodulekindWithES5Target7_es2015.2.minified.js @@ -1 +1,2 @@ export var N; +N || (N = {}); diff --git a/crates/swc/tests/tsc-references/esnextmodulekindWithES5Target7_es5.2.minified.js b/crates/swc/tests/tsc-references/esnextmodulekindWithES5Target7_es5.2.minified.js index 26b040ffcd3..ab9feb11942 100644 --- a/crates/swc/tests/tsc-references/esnextmodulekindWithES5Target7_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/esnextmodulekindWithES5Target7_es5.2.minified.js @@ -1 +1,2 @@ export var N; +N || (N = {}); diff --git a/crates/swc/tests/tsc-references/exportCodeGen_es2015.2.minified.js b/crates/swc/tests/tsc-references/exportCodeGen_es2015.2.minified.js index 5d284d5e42a..5df160e094a 100644 --- a/crates/swc/tests/tsc-references/exportCodeGen_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/exportCodeGen_es2015.2.minified.js @@ -1,5 +1,5 @@ -var A, D, E, F; -(A || (A = {})).x = 12, (D || (D = {})).yes = function() { +var A, B, C, D, E, F; +(A || (A = {})).x = 12, B || (B = {}), C || (C = {}), (D || (D = {})).yes = function() { return !0; }, function(E1) { var Color; @@ -9,4 +9,6 @@ var A, D, E, F; var Color; let Color1; (Color = Color1 || (Color1 = {}))[Color.Red = 0] = "Red"; + let M; + M || (M = {}); }(F || (F = {})); diff --git a/crates/swc/tests/tsc-references/exportCodeGen_es5.2.minified.js b/crates/swc/tests/tsc-references/exportCodeGen_es5.2.minified.js index 264377d9a89..48bfa2a6d61 100644 --- a/crates/swc/tests/tsc-references/exportCodeGen_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/exportCodeGen_es5.2.minified.js @@ -1,18 +1,19 @@ -var A, D, E, F; +var A, B, C, D, E, F; import * as swcHelpers from "@swc/helpers"; -(A || (A = {})).x = 12, (D || (D = {})).yes = function() { +(A || (A = {})).x = 12, B || (B = {}), C || (C = {}), (D || (D = {})).yes = function() { return !0; }, function(E1) { (Color = E1.Color || (E1.Color = {}))[Color.Red = 0] = "Red", E1.fn = function() {}; - var Color, C = function() { + var Color, C1 = function() { "use strict"; - swcHelpers.classCallCheck(this, C); + swcHelpers.classCallCheck(this, C1); }; - E1.C = C, (E1.M || (E1.M = {})).x = 42; + E1.C = C1, (E1.M || (E1.M = {})).x = 42; }(E || (E = {})), function(F) { (Color1 = Color || (Color = {}))[Color1.Red = 0] = "Red"; - var Color, Color1, C = function() { + var Color, M, Color1, C2 = function() { "use strict"; - swcHelpers.classCallCheck(this, C); + swcHelpers.classCallCheck(this, C2); }; + M || (M = {}); }(F || (F = {})); diff --git a/crates/swc/tests/tsc-references/functionNameConflicts_es2015.2.minified.js b/crates/swc/tests/tsc-references/functionNameConflicts_es2015.2.minified.js new file mode 100644 index 00000000000..cf77a4b72fa --- /dev/null +++ b/crates/swc/tests/tsc-references/functionNameConflicts_es2015.2.minified.js @@ -0,0 +1,2 @@ +var M; +M || (M = {}); diff --git a/crates/swc/tests/tsc-references/functionNameConflicts_es5.2.minified.js b/crates/swc/tests/tsc-references/functionNameConflicts_es5.2.minified.js new file mode 100644 index 00000000000..cf77a4b72fa --- /dev/null +++ b/crates/swc/tests/tsc-references/functionNameConflicts_es5.2.minified.js @@ -0,0 +1,2 @@ +var M; +M || (M = {}); diff --git a/crates/swc/tests/tsc-references/generatedContextualTyping_es2015.2.minified.js b/crates/swc/tests/tsc-references/generatedContextualTyping_es2015.2.minified.js index d397587d06a..4d6d3f4021c 100644 --- a/crates/swc/tests/tsc-references/generatedContextualTyping_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/generatedContextualTyping_es2015.2.minified.js @@ -1,7 +1,7 @@ class Base { } new Base(); -var x193, x194, x195, x196, x197, x198, x199, x200, x201, x202, x203, x204, d1 = new class extends Base { +var x181, x182, x183, x184, x185, x186, x187, x188, x189, x190, x191, x192, x193, x194, x195, x196, x197, x198, x199, x200, x201, x202, x203, x204, d1 = new class extends Base { }(), d2 = new class extends Base { }(); (class { @@ -184,7 +184,7 @@ var x193, x194, x195, x196, x197, x198, x199, x200, x201, x202, x203, x204, d1 = d1, d2 ] -}, (x193 || (x193 = {})).t = ()=>[ +}, x181 || (x181 = {}), x182 || (x182 = {}), x183 || (x183 = {}), x184 || (x184 = {}), x185 || (x185 = {}), x186 || (x186 = {}), x187 || (x187 = {}), x188 || (x188 = {}), x189 || (x189 = {}), x190 || (x190 = {}), x191 || (x191 = {}), x192 || (x192 = {}), (x193 || (x193 = {})).t = ()=>[ d1, d2 ] diff --git a/crates/swc/tests/tsc-references/generatedContextualTyping_es5.2.minified.js b/crates/swc/tests/tsc-references/generatedContextualTyping_es5.2.minified.js index 51196ce21bd..b9e9ef8f0e4 100644 --- a/crates/swc/tests/tsc-references/generatedContextualTyping_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatedContextualTyping_es5.2.minified.js @@ -1,5 +1,5 @@ import * as swcHelpers from "@swc/helpers"; -var x193, x194, x195, x196, x197, x198, x199, x200, x201, x202, x203, x204, Base = function() { +var x181, x182, x183, x184, x185, x186, x187, x188, x189, x190, x191, x192, x193, x194, x195, x196, x197, x198, x199, x200, x201, x202, x203, x204, Base = function() { "use strict"; swcHelpers.classCallCheck(this, Base); }, Derived1 = function(Base1) { @@ -865,7 +865,7 @@ var x85 = function() { }; swcHelpers.classCallCheck(this, x120), this.parm = parm; }; -(x193 || (x193 = {})).t = function() { +x181 || (x181 = {}), x182 || (x182 = {}), x183 || (x183 = {}), x184 || (x184 = {}), x185 || (x185 = {}), x186 || (x186 = {}), x187 || (x187 = {}), x188 || (x188 = {}), x189 || (x189 = {}), x190 || (x190 = {}), x191 || (x191 = {}), x192 || (x192 = {}), (x193 || (x193 = {})).t = function() { return [ d1, d2 diff --git a/crates/swc/tests/tsc-references/generatorOverloads5_es2015.2.minified.js b/crates/swc/tests/tsc-references/generatorOverloads5_es2015.2.minified.js new file mode 100644 index 00000000000..cf77a4b72fa --- /dev/null +++ b/crates/swc/tests/tsc-references/generatorOverloads5_es2015.2.minified.js @@ -0,0 +1,2 @@ +var M; +M || (M = {}); diff --git a/crates/swc/tests/tsc-references/genericCallWithObjectTypeArgsAndConstraints3_es2015.2.minified.js b/crates/swc/tests/tsc-references/genericCallWithObjectTypeArgsAndConstraints3_es2015.2.minified.js index b8a1b92ad40..c6cb077975e 100644 --- a/crates/swc/tests/tsc-references/genericCallWithObjectTypeArgsAndConstraints3_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/genericCallWithObjectTypeArgsAndConstraints3_es2015.2.minified.js @@ -8,7 +8,7 @@ function f2(a) {} function f3(y, x) { return y(null); } -f2({ +new Derived(), new Derived2(), f2({ x: new Derived(), y: new Derived2() }), f2({ diff --git a/crates/swc/tests/tsc-references/genericCallWithObjectTypeArgsAndConstraints3_es5.2.minified.js b/crates/swc/tests/tsc-references/genericCallWithObjectTypeArgsAndConstraints3_es5.2.minified.js index 4dc507893f5..8f8d6d17871 100644 --- a/crates/swc/tests/tsc-references/genericCallWithObjectTypeArgsAndConstraints3_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/genericCallWithObjectTypeArgsAndConstraints3_es5.2.minified.js @@ -23,7 +23,7 @@ function f2(a) {} function f3(y, x) { return y(null); } -f2({ +new Derived(), new Derived2(), f2({ x: new Derived(), y: new Derived2() }), f2({ diff --git a/crates/swc/tests/tsc-references/genericCallWithOverloadedConstructorTypedArguments2_es2015.2.minified.js b/crates/swc/tests/tsc-references/genericCallWithOverloadedConstructorTypedArguments2_es2015.2.minified.js new file mode 100644 index 00000000000..5d8f942b601 --- /dev/null +++ b/crates/swc/tests/tsc-references/genericCallWithOverloadedConstructorTypedArguments2_es2015.2.minified.js @@ -0,0 +1,2 @@ +var NonGenericParameter, GenericParameter; +NonGenericParameter || (NonGenericParameter = {}), GenericParameter || (GenericParameter = {}); diff --git a/crates/swc/tests/tsc-references/genericCallWithOverloadedConstructorTypedArguments2_es5.2.minified.js b/crates/swc/tests/tsc-references/genericCallWithOverloadedConstructorTypedArguments2_es5.2.minified.js index 2bb7547e770..4df18878533 100644 --- a/crates/swc/tests/tsc-references/genericCallWithOverloadedConstructorTypedArguments2_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/genericCallWithOverloadedConstructorTypedArguments2_es5.2.minified.js @@ -1,5 +1,5 @@ -var GenericParameter; -!function(GenericParameter) { +var NonGenericParameter, GenericParameter; +NonGenericParameter || (NonGenericParameter = {}), function(GenericParameter) { var c, foo7 = function(x, cb) { return cb; }; diff --git a/crates/swc/tests/tsc-references/genericCallWithOverloadedConstructorTypedArguments_es2015.2.minified.js b/crates/swc/tests/tsc-references/genericCallWithOverloadedConstructorTypedArguments_es2015.2.minified.js index 20cda8e59c9..fbe3b2f9f68 100644 --- a/crates/swc/tests/tsc-references/genericCallWithOverloadedConstructorTypedArguments_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/genericCallWithOverloadedConstructorTypedArguments_es2015.2.minified.js @@ -1,8 +1,8 @@ -var NonGenericParameter; +var NonGenericParameter, GenericParameter; !function(NonGenericParameter) { var b; function foo4(cb) { return new cb(null); } foo4(void 0), foo4(b); -}(NonGenericParameter || (NonGenericParameter = {})); +}(NonGenericParameter || (NonGenericParameter = {})), GenericParameter || (GenericParameter = {}); diff --git a/crates/swc/tests/tsc-references/genericCallWithOverloadedFunctionTypedArguments2_es2015.2.minified.js b/crates/swc/tests/tsc-references/genericCallWithOverloadedFunctionTypedArguments2_es2015.2.minified.js new file mode 100644 index 00000000000..5d8f942b601 --- /dev/null +++ b/crates/swc/tests/tsc-references/genericCallWithOverloadedFunctionTypedArguments2_es2015.2.minified.js @@ -0,0 +1,2 @@ +var NonGenericParameter, GenericParameter; +NonGenericParameter || (NonGenericParameter = {}), GenericParameter || (GenericParameter = {}); diff --git a/crates/swc/tests/tsc-references/genericCallWithOverloadedFunctionTypedArguments_es2015.2.minified.js b/crates/swc/tests/tsc-references/genericCallWithOverloadedFunctionTypedArguments_es2015.2.minified.js new file mode 100644 index 00000000000..5d8f942b601 --- /dev/null +++ b/crates/swc/tests/tsc-references/genericCallWithOverloadedFunctionTypedArguments_es2015.2.minified.js @@ -0,0 +1,2 @@ +var NonGenericParameter, GenericParameter; +NonGenericParameter || (NonGenericParameter = {}), GenericParameter || (GenericParameter = {}); diff --git a/crates/swc/tests/tsc-references/heterogeneousArrayLiterals_es2015.2.minified.js b/crates/swc/tests/tsc-references/heterogeneousArrayLiterals_es2015.2.minified.js new file mode 100644 index 00000000000..377c01b9418 --- /dev/null +++ b/crates/swc/tests/tsc-references/heterogeneousArrayLiterals_es2015.2.minified.js @@ -0,0 +1,6 @@ +var WithContextualType; +class Base { +} +class Derived extends Base { +} +Derived || (Derived = {}), WithContextualType || (WithContextualType = {}); diff --git a/crates/swc/tests/tsc-references/heterogeneousArrayLiterals_es5.2.minified.js b/crates/swc/tests/tsc-references/heterogeneousArrayLiterals_es5.2.minified.js index ed6f8f9b52e..52e9f6be561 100644 --- a/crates/swc/tests/tsc-references/heterogeneousArrayLiterals_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/heterogeneousArrayLiterals_es5.2.minified.js @@ -1,5 +1,5 @@ import * as swcHelpers from "@swc/helpers"; -var Base = function() { +var WithContextualType, Base = function() { "use strict"; swcHelpers.classCallCheck(this, Base); }, Derived = function(Base1) { @@ -19,3 +19,4 @@ var Base = function() { } return Derived2; }(Base); +Derived || (Derived = {}), WithContextualType || (WithContextualType = {}); diff --git a/crates/swc/tests/tsc-references/implementingAnInterfaceExtendingClassWithPrivates2_es2015.2.minified.js b/crates/swc/tests/tsc-references/implementingAnInterfaceExtendingClassWithPrivates2_es2015.2.minified.js index bcbfcce8728..f208a70d892 100644 --- a/crates/swc/tests/tsc-references/implementingAnInterfaceExtendingClassWithPrivates2_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/implementingAnInterfaceExtendingClassWithPrivates2_es2015.2.minified.js @@ -1,5 +1,5 @@ -var M2; -!function(M2) { +var M, M2; +M || (M = {}), function(M2) { var b; b.z, b.x, b.y; }(M2 || (M2 = {})); diff --git a/crates/swc/tests/tsc-references/importAliasIdentifiers_es2015.2.minified.js b/crates/swc/tests/tsc-references/importAliasIdentifiers_es2015.2.minified.js index ecd97bb7429..5d6ab967ccc 100644 --- a/crates/swc/tests/tsc-references/importAliasIdentifiers_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/importAliasIdentifiers_es2015.2.minified.js @@ -4,4 +4,13 @@ var moduleA; this.x = x, this.y = y; } }; +class clodule { +} +function fundule() { + return { + x: 0, + y: 0 + }; +} +clodule || (clodule = {}), fundule || (fundule = {}); export { }; diff --git a/crates/swc/tests/tsc-references/importAliasIdentifiers_es5.2.minified.js b/crates/swc/tests/tsc-references/importAliasIdentifiers_es5.2.minified.js index 9ad45853ef0..0e840b9142c 100644 --- a/crates/swc/tests/tsc-references/importAliasIdentifiers_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importAliasIdentifiers_es5.2.minified.js @@ -10,3 +10,10 @@ var moduleA, clodule = function() { "use strict"; swcHelpers.classCallCheck(this, clodule); }; +function fundule() { + return { + x: 0, + y: 0 + }; +} +clodule || (clodule = {}), fundule || (fundule = {}); diff --git a/crates/swc/tests/tsc-references/importStatementsInterfaces_es2015.2.minified.js b/crates/swc/tests/tsc-references/importStatementsInterfaces_es2015.2.minified.js index 507264a126e..ffda673527d 100644 --- a/crates/swc/tests/tsc-references/importStatementsInterfaces_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/importStatementsInterfaces_es2015.2.minified.js @@ -1,4 +1,4 @@ -var E; -(E || (E = {})).xDist = function(x) { +var C, D, E; +C || (C = {}), D || (D = {}), (E || (E = {})).xDist = function(x) { return 0 - x.x; }; diff --git a/crates/swc/tests/tsc-references/importStatementsInterfaces_es5.2.minified.js b/crates/swc/tests/tsc-references/importStatementsInterfaces_es5.2.minified.js index 507264a126e..ffda673527d 100644 --- a/crates/swc/tests/tsc-references/importStatementsInterfaces_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importStatementsInterfaces_es5.2.minified.js @@ -1,4 +1,4 @@ -var E; -(E || (E = {})).xDist = function(x) { +var C, D, E; +C || (C = {}), D || (D = {}), (E || (E = {})).xDist = function(x) { return 0 - x.x; }; diff --git a/crates/swc/tests/tsc-references/importStatements_es2015.2.minified.js b/crates/swc/tests/tsc-references/importStatements_es2015.2.minified.js index 3635ddfdc61..b51197081dc 100644 --- a/crates/swc/tests/tsc-references/importStatements_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/importStatements_es2015.2.minified.js @@ -1,4 +1,4 @@ -var A, D, E; +var A, C, D, E; !function(A1) { class Point { constructor(x, y){ @@ -6,7 +6,7 @@ var A, D, E; } } A1.Point = Point, A1.Origin = new Point(0, 0); -}(A || (A = {})), D || (D = {}), new A.Point(1, 1), function(E1) { +}(A || (A = {})), C || (C = {}), D || (D = {}), new A.Point(1, 1), function(E1) { var a = A; E1.xDist = function(x) { return a.Origin.x - x.x; diff --git a/crates/swc/tests/tsc-references/importStatements_es5.2.minified.js b/crates/swc/tests/tsc-references/importStatements_es5.2.minified.js index b5c7fc65ad3..7366532c937 100644 --- a/crates/swc/tests/tsc-references/importStatements_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/importStatements_es5.2.minified.js @@ -1,4 +1,4 @@ -var A, D, E; +var A, C, D, E; import * as swcHelpers from "@swc/helpers"; !function(A1) { var Point = function(x, y) { @@ -6,7 +6,7 @@ import * as swcHelpers from "@swc/helpers"; swcHelpers.classCallCheck(this, Point), this.x = x, this.y = y; }; A1.Point = Point, A1.Origin = new Point(0, 0); -}(A || (A = {})), D || (D = {}), new A.Point(1, 1), function(E1) { +}(A || (A = {})), C || (C = {}), D || (D = {}), new A.Point(1, 1), function(E1) { var a = A; E1.xDist = function(x) { return a.Origin.x - x.x; diff --git a/crates/swc/tests/tsc-references/jsDeclarationsEnums_es2015.2.minified.js b/crates/swc/tests/tsc-references/jsDeclarationsEnums_es2015.2.minified.js index 997a71a6dc0..fbd736fe04a 100644 --- a/crates/swc/tests/tsc-references/jsDeclarationsEnums_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/jsDeclarationsEnums_es2015.2.minified.js @@ -1,11 +1,15 @@ var C, DD; export var A; +!function(A) {}(A || (A = {})); export var B; !function(B) { B[B.Member = 0] = "Member"; -}(B || (B = {})); +}(B || (B = {})), C = {}; +!function(DD) {}(DD || (DD = {})); export var E; +!function(E) {}(E || (E = {})); export var F; +!function(F) {}(F || (F = {})); export var G; !function(G) { G[G.A = 1] = "A", G[G.B = 2] = "B", G[G.C = 3] = "C"; diff --git a/crates/swc/tests/tsc-references/jsDeclarationsEnums_es5.2.minified.js b/crates/swc/tests/tsc-references/jsDeclarationsEnums_es5.2.minified.js index 997a71a6dc0..fbd736fe04a 100644 --- a/crates/swc/tests/tsc-references/jsDeclarationsEnums_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/jsDeclarationsEnums_es5.2.minified.js @@ -1,11 +1,15 @@ var C, DD; export var A; +!function(A) {}(A || (A = {})); export var B; !function(B) { B[B.Member = 0] = "Member"; -}(B || (B = {})); +}(B || (B = {})), C = {}; +!function(DD) {}(DD || (DD = {})); export var E; +!function(E) {}(E || (E = {})); export var F; +!function(F) {}(F || (F = {})); export var G; !function(G) { G[G.A = 1] = "A", G[G.B = 2] = "B", G[G.C = 3] = "C"; diff --git a/crates/swc/tests/tsc-references/mergedInterfacesWithInheritedPrivates3_es2015.2.minified.js b/crates/swc/tests/tsc-references/mergedInterfacesWithInheritedPrivates3_es2015.2.minified.js new file mode 100644 index 00000000000..cf77a4b72fa --- /dev/null +++ b/crates/swc/tests/tsc-references/mergedInterfacesWithInheritedPrivates3_es2015.2.minified.js @@ -0,0 +1,2 @@ +var M; +M || (M = {}); diff --git a/crates/swc/tests/tsc-references/mergedInterfacesWithMultipleBases2_es2015.2.minified.js b/crates/swc/tests/tsc-references/mergedInterfacesWithMultipleBases2_es2015.2.minified.js index 670db71173f..02b97e97114 100644 --- a/crates/swc/tests/tsc-references/mergedInterfacesWithMultipleBases2_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/mergedInterfacesWithMultipleBases2_es2015.2.minified.js @@ -1 +1,2 @@ -(void 0).a; +var M; +(void 0).a, M || (M = {}); diff --git a/crates/swc/tests/tsc-references/mergedInterfacesWithMultipleBases_es2015.2.minified.js b/crates/swc/tests/tsc-references/mergedInterfacesWithMultipleBases_es2015.2.minified.js index 670db71173f..02b97e97114 100644 --- a/crates/swc/tests/tsc-references/mergedInterfacesWithMultipleBases_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/mergedInterfacesWithMultipleBases_es2015.2.minified.js @@ -1 +1,2 @@ -(void 0).a; +var M; +(void 0).a, M || (M = {}); diff --git a/crates/swc/tests/tsc-references/moduleWithStatementsOfEveryKind_es2015.2.minified.js b/crates/swc/tests/tsc-references/moduleWithStatementsOfEveryKind_es2015.2.minified.js index f1e19750894..158c1d1fb9c 100644 --- a/crates/swc/tests/tsc-references/moduleWithStatementsOfEveryKind_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/moduleWithStatementsOfEveryKind_es2015.2.minified.js @@ -1,6 +1,8 @@ var A, Y; !function(A) { var Color; + let Module; + Module || (Module = {}); let Color1; (Color = Color1 || (Color1 = {}))[Color.Blue = 0] = "Blue", Color[Color.Red = 1] = "Red"; }(A || (A = {})), function(Y1) { @@ -15,7 +17,7 @@ var A, Y; } Y1.AA = AA, Y1.B = class extends AA { }, Y1.BB = class extends A1 { - }, (Color = Y1.Color || (Y1.Color = {}))[Color.Blue = 0] = "Blue", Color[Color.Red = 1] = "Red", Y1.x = 12, Y1.F = F, Y1.array = null, Y1.fn = (s)=>'hello ' + s + }, Y1.Module || (Y1.Module = {}), (Color = Y1.Color || (Y1.Color = {}))[Color.Blue = 0] = "Blue", Color[Color.Red = 1] = "Red", Y1.x = 12, Y1.F = F, Y1.array = null, Y1.fn = (s)=>'hello ' + s , Y1.ol = { s: 'hello', id: 2, diff --git a/crates/swc/tests/tsc-references/nameCollision_es2015.2.minified.js b/crates/swc/tests/tsc-references/nameCollision_es2015.2.minified.js index e67e53fff85..1ff8bb3c6fc 100644 --- a/crates/swc/tests/tsc-references/nameCollision_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/nameCollision_es2015.2.minified.js @@ -1,7 +1,8 @@ -var X, Y, D; -!function(X1) { - X1.Y || (X1.Y = {}); -}(X || (X = {})), function(Y3) { - var Y1, Y2; - (Y2 = (Y1 = Y3.Y || (Y3.Y = {})).Y || (Y1.Y = {}))[Y2.Red = 0] = "Red", Y2[Y2.Blue = 1] = "Blue"; +var A, B, X, Y, D; +A || (A = {}), B || (B = {}), B || (B = {}), function(X1) { + var Y1; + (Y1 = X1.Y || (X1.Y = {})).Z || (Y1.Z = {}); +}(X || (X = {})), function(Y4) { + var Y2, Y3; + (Y3 = (Y2 = Y4.Y || (Y4.Y = {})).Y || (Y2.Y = {}))[Y3.Red = 0] = "Red", Y3[Y3.Blue = 1] = "Blue"; }(Y || (Y = {})), (D || (D = {})).E = 'hello'; diff --git a/crates/swc/tests/tsc-references/nameCollision_es5.2.minified.js b/crates/swc/tests/tsc-references/nameCollision_es5.2.minified.js index a16f6efc86f..0621ac9e68f 100644 --- a/crates/swc/tests/tsc-references/nameCollision_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/nameCollision_es5.2.minified.js @@ -1,13 +1,14 @@ -var B, X, Y, D; +var A, B, X, Y, D; import * as swcHelpers from "@swc/helpers"; -!function(B) { +A || (A = {}), B || (B = {}), function(B) { var B1 = function() { "use strict"; swcHelpers.classCallCheck(this, B1); }; }(B || (B = {})), function(X1) { - X1.Y || (X1.Y = {}); -}(X || (X = {})), function(Y2) { - var Y1, _$Y; - (_$Y = (Y1 = Y2.Y || (Y2.Y = {})).Y || (Y1.Y = {}))[_$Y.Red = 0] = "Red", _$Y[_$Y.Blue = 1] = "Blue"; + var Y1; + (Y1 = X1.Y || (X1.Y = {})).Z || (Y1.Z = {}); +}(X || (X = {})), function(Y3) { + var Y2, _$Y; + (_$Y = (Y2 = Y3.Y || (Y3.Y = {})).Y || (Y2.Y = {}))[_$Y.Red = 0] = "Red", _$Y[_$Y.Blue = 1] = "Blue"; }(Y || (Y = {})), (D || (D = {})).E = "hello"; diff --git a/crates/swc/tests/tsc-references/negateOperatorWithEnumType_es2015.2.minified.js b/crates/swc/tests/tsc-references/negateOperatorWithEnumType_es2015.2.minified.js index d005b67f335..b3a017d6fdf 100644 --- a/crates/swc/tests/tsc-references/negateOperatorWithEnumType_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/negateOperatorWithEnumType_es2015.2.minified.js @@ -1,4 +1,4 @@ -var ENUM1; -!function(ENUM1) { +var ENUM, ENUM1; +!function(ENUM) {}(ENUM || (ENUM = {})), function(ENUM1) { ENUM1[ENUM1.A = 0] = "A", ENUM1[ENUM1.B = 1] = "B", ENUM1[ENUM1[""] = 2] = ""; }(ENUM1 || (ENUM1 = {})), ENUM1.B, ENUM1.B, ENUM1[""], ENUM1.B; diff --git a/crates/swc/tests/tsc-references/negateOperatorWithEnumType_es5.2.minified.js b/crates/swc/tests/tsc-references/negateOperatorWithEnumType_es5.2.minified.js index d005b67f335..b3a017d6fdf 100644 --- a/crates/swc/tests/tsc-references/negateOperatorWithEnumType_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/negateOperatorWithEnumType_es5.2.minified.js @@ -1,4 +1,4 @@ -var ENUM1; -!function(ENUM1) { +var ENUM, ENUM1; +!function(ENUM) {}(ENUM || (ENUM = {})), function(ENUM1) { ENUM1[ENUM1.A = 0] = "A", ENUM1[ENUM1.B = 1] = "B", ENUM1[ENUM1[""] = 2] = ""; }(ENUM1 || (ENUM1 = {})), ENUM1.B, ENUM1.B, ENUM1[""], ENUM1.B; diff --git a/crates/swc/tests/tsc-references/nestedModules_es2015.2.minified.js b/crates/swc/tests/tsc-references/nestedModules_es2015.2.minified.js index 52a3caf8ecb..da78e6e430a 100644 --- a/crates/swc/tests/tsc-references/nestedModules_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/nestedModules_es2015.2.minified.js @@ -1,5 +1,7 @@ -var M2; -!function(M21) { +var A, M2; +!function(A1) { + A1.B || (A1.B = {}); +}(A || (A = {})), function(M21) { var Point; (M21.X || (M21.X = {})).Point = Point; }(M2 || (M2 = {})), M2.X.Point; diff --git a/crates/swc/tests/tsc-references/nestedModules_es5.2.minified.js b/crates/swc/tests/tsc-references/nestedModules_es5.2.minified.js index 52a3caf8ecb..da78e6e430a 100644 --- a/crates/swc/tests/tsc-references/nestedModules_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/nestedModules_es5.2.minified.js @@ -1,5 +1,7 @@ -var M2; -!function(M21) { +var A, M2; +!function(A1) { + A1.B || (A1.B = {}); +}(A || (A = {})), function(M21) { var Point; (M21.X || (M21.X = {})).Point = Point; }(M2 || (M2 = {})), M2.X.Point; diff --git a/crates/swc/tests/tsc-references/newTargetNarrowing_es2015.2.minified.js b/crates/swc/tests/tsc-references/newTargetNarrowing_es2015.2.minified.js index 623ec8e1fca..2b3130ca305 100644 --- a/crates/swc/tests/tsc-references/newTargetNarrowing_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/newTargetNarrowing_es2015.2.minified.js @@ -1,3 +1,3 @@ (function() { - new.target.marked; + !0 === new.target.marked && new.target.marked; }).marked = !0; diff --git a/crates/swc/tests/tsc-references/newTargetNarrowing_es5.2.minified.js b/crates/swc/tests/tsc-references/newTargetNarrowing_es5.2.minified.js index 2400682bb70..d52167b3955 100644 --- a/crates/swc/tests/tsc-references/newTargetNarrowing_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/newTargetNarrowing_es5.2.minified.js @@ -1,5 +1,5 @@ import * as swcHelpers from "@swc/helpers"; function f() { - (swcHelpers._instanceof(this, f) ? this.constructor : void 0).marked; + !0 === (swcHelpers._instanceof(this, f) ? this.constructor : void 0).marked && (swcHelpers._instanceof(this, f) ? this.constructor : void 0).marked; } f.marked = !0; diff --git a/crates/swc/tests/tsc-references/nonGenericTypeReferenceWithTypeArguments_es2015.2.minified.js b/crates/swc/tests/tsc-references/nonGenericTypeReferenceWithTypeArguments_es2015.2.minified.js new file mode 100644 index 00000000000..651e5b2b096 --- /dev/null +++ b/crates/swc/tests/tsc-references/nonGenericTypeReferenceWithTypeArguments_es2015.2.minified.js @@ -0,0 +1,2 @@ +var E; +!function(E) {}(E || (E = {})); diff --git a/crates/swc/tests/tsc-references/nonGenericTypeReferenceWithTypeArguments_es5.2.minified.js b/crates/swc/tests/tsc-references/nonGenericTypeReferenceWithTypeArguments_es5.2.minified.js index 7bd16f52411..f5512b25f83 100644 --- a/crates/swc/tests/tsc-references/nonGenericTypeReferenceWithTypeArguments_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/nonGenericTypeReferenceWithTypeArguments_es5.2.minified.js @@ -1,5 +1,6 @@ import * as swcHelpers from "@swc/helpers"; -var C = function() { +var E, C = function() { "use strict"; swcHelpers.classCallCheck(this, C); }; +!function(E) {}(E || (E = {})); diff --git a/crates/swc/tests/tsc-references/parserEnum3_es2015.2.minified.js b/crates/swc/tests/tsc-references/parserEnum3_es2015.2.minified.js index 6d2ba1781d6..682fe9645cf 100644 --- a/crates/swc/tests/tsc-references/parserEnum3_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/parserEnum3_es2015.2.minified.js @@ -1 +1,2 @@ export var SignatureFlags; +!function(SignatureFlags) {}(SignatureFlags || (SignatureFlags = {})); diff --git a/crates/swc/tests/tsc-references/parserEnum3_es5.2.minified.js b/crates/swc/tests/tsc-references/parserEnum3_es5.2.minified.js index 6d2ba1781d6..682fe9645cf 100644 --- a/crates/swc/tests/tsc-references/parserEnum3_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/parserEnum3_es5.2.minified.js @@ -1 +1,2 @@ export var SignatureFlags; +!function(SignatureFlags) {}(SignatureFlags || (SignatureFlags = {})); diff --git a/crates/swc/tests/tsc-references/parserEnumDeclaration2.d_es2015.2.minified.js b/crates/swc/tests/tsc-references/parserEnumDeclaration2.d_es2015.2.minified.js new file mode 100644 index 00000000000..651e5b2b096 --- /dev/null +++ b/crates/swc/tests/tsc-references/parserEnumDeclaration2.d_es2015.2.minified.js @@ -0,0 +1,2 @@ +var E; +!function(E) {}(E || (E = {})); diff --git a/crates/swc/tests/tsc-references/parserEnumDeclaration2.d_es5.2.minified.js b/crates/swc/tests/tsc-references/parserEnumDeclaration2.d_es5.2.minified.js new file mode 100644 index 00000000000..651e5b2b096 --- /dev/null +++ b/crates/swc/tests/tsc-references/parserEnumDeclaration2.d_es5.2.minified.js @@ -0,0 +1,2 @@ +var E; +!function(E) {}(E || (E = {})); diff --git a/crates/swc/tests/tsc-references/parserSuperExpression1_es2015.2.minified.js b/crates/swc/tests/tsc-references/parserSuperExpression1_es2015.2.minified.js new file mode 100644 index 00000000000..2c5ecb54ef0 --- /dev/null +++ b/crates/swc/tests/tsc-references/parserSuperExpression1_es2015.2.minified.js @@ -0,0 +1,4 @@ +var M1; +!function(M11) { + M11.M2 || (M11.M2 = {}); +}(M1 || (M1 = {})); diff --git a/crates/swc/tests/tsc-references/parserSuperExpression4_es2015.2.minified.js b/crates/swc/tests/tsc-references/parserSuperExpression4_es2015.2.minified.js new file mode 100644 index 00000000000..2c5ecb54ef0 --- /dev/null +++ b/crates/swc/tests/tsc-references/parserSuperExpression4_es2015.2.minified.js @@ -0,0 +1,4 @@ +var M1; +!function(M11) { + M11.M2 || (M11.M2 = {}); +}(M1 || (M1 = {})); diff --git a/crates/swc/tests/tsc-references/plusOperatorWithEnumType_es2015.2.minified.js b/crates/swc/tests/tsc-references/plusOperatorWithEnumType_es2015.2.minified.js index c644a12a3fb..d4391bafcee 100644 --- a/crates/swc/tests/tsc-references/plusOperatorWithEnumType_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/plusOperatorWithEnumType_es2015.2.minified.js @@ -1,4 +1,4 @@ var ENUM, ENUM1; -!function(ENUM1) { +!function(ENUM) {}(ENUM || (ENUM = {})), function(ENUM1) { ENUM1[ENUM1.A = 0] = "A", ENUM1[ENUM1.B = 1] = "B", ENUM1[ENUM1[""] = 2] = ""; }(ENUM1 || (ENUM1 = {})), ENUM1.A, ENUM[0], ENUM1.B, ENUM1.B; diff --git a/crates/swc/tests/tsc-references/plusOperatorWithEnumType_es5.2.minified.js b/crates/swc/tests/tsc-references/plusOperatorWithEnumType_es5.2.minified.js index c644a12a3fb..d4391bafcee 100644 --- a/crates/swc/tests/tsc-references/plusOperatorWithEnumType_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/plusOperatorWithEnumType_es5.2.minified.js @@ -1,4 +1,4 @@ var ENUM, ENUM1; -!function(ENUM1) { +!function(ENUM) {}(ENUM || (ENUM = {})), function(ENUM1) { ENUM1[ENUM1.A = 0] = "A", ENUM1[ENUM1.B = 1] = "B", ENUM1[ENUM1[""] = 2] = ""; }(ENUM1 || (ENUM1 = {})), ENUM1.A, ENUM[0], ENUM1.B, ENUM1.B; diff --git a/crates/swc/tests/tsc-references/scopeResolutionIdentifiers_es2015.2.minified.js b/crates/swc/tests/tsc-references/scopeResolutionIdentifiers_es2015.2.minified.js index b59b3e020fd..8e2799a6586 100644 --- a/crates/swc/tests/tsc-references/scopeResolutionIdentifiers_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/scopeResolutionIdentifiers_es2015.2.minified.js @@ -1,8 +1,8 @@ -var M1, M3; +var M1, M2, M3; !function(M11) { var s; M11.s = s; -}(M1 || (M1 = {})), function(M3) { +}(M1 || (M1 = {})), M2 || (M2 = {}), function(M3) { let M4; M4 || (M4 = {}); }(M3 || (M3 = {})); diff --git a/crates/swc/tests/tsc-references/scopeResolutionIdentifiers_es5.2.minified.js b/crates/swc/tests/tsc-references/scopeResolutionIdentifiers_es5.2.minified.js index deca7b95671..e09d1c8f949 100644 --- a/crates/swc/tests/tsc-references/scopeResolutionIdentifiers_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/scopeResolutionIdentifiers_es5.2.minified.js @@ -2,8 +2,8 @@ import * as swcHelpers from "@swc/helpers"; !function(M11) { var s; M11.s = s; -}(M1 || (M1 = {})); -var M1, M3, C = function() { +}(M1 || (M1 = {})), M2 || (M2 = {}); +var M1, M2, M3, C = function() { "use strict"; function C() { swcHelpers.classCallCheck(this, C), this.n = this.s; diff --git a/crates/swc/tests/tsc-references/shadowedInternalModule_es2015.2.minified.js b/crates/swc/tests/tsc-references/shadowedInternalModule_es2015.2.minified.js index d0f5a2ebf5d..58aa7fdc12a 100644 --- a/crates/swc/tests/tsc-references/shadowedInternalModule_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/shadowedInternalModule_es2015.2.minified.js @@ -1,6 +1,6 @@ -var A, X; +var A, B, X, Z; (A || (A = {})).Point = { x: 0, y: 0 -}, (X || (X = {})).Y = class { -}; +}, B || (B = {}), (X || (X = {})).Y = class { +}, Z || (Z = {}); diff --git a/crates/swc/tests/tsc-references/shadowedInternalModule_es5.2.minified.js b/crates/swc/tests/tsc-references/shadowedInternalModule_es5.2.minified.js index 4b158429fc9..fb5a4dd0fbc 100644 --- a/crates/swc/tests/tsc-references/shadowedInternalModule_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/shadowedInternalModule_es5.2.minified.js @@ -1,12 +1,12 @@ -var A, X; +var A, B, X, Z; import * as swcHelpers from "@swc/helpers"; (A || (A = {})).Point = { x: 0, y: 0 -}, function(X1) { +}, B || (B = {}), function(X1) { var Y = function() { "use strict"; swcHelpers.classCallCheck(this, Y); }; X1.Y = Y; -}(X || (X = {})); +}(X || (X = {})), Z || (Z = {}); diff --git a/crates/swc/tests/tsc-references/subtypesOfTypeParameterWithRecursiveConstraints_es2015.2.minified.js b/crates/swc/tests/tsc-references/subtypesOfTypeParameterWithRecursiveConstraints_es2015.2.minified.js new file mode 100644 index 00000000000..bd42169c02c --- /dev/null +++ b/crates/swc/tests/tsc-references/subtypesOfTypeParameterWithRecursiveConstraints_es2015.2.minified.js @@ -0,0 +1,2 @@ +var M1, M2; +M1 || (M1 = {}), M2 || (M2 = {}); diff --git a/crates/swc/tests/tsc-references/subtypingWithNumericIndexer3_es2015.2.minified.js b/crates/swc/tests/tsc-references/subtypingWithNumericIndexer3_es2015.2.minified.js new file mode 100644 index 00000000000..4558588552f --- /dev/null +++ b/crates/swc/tests/tsc-references/subtypingWithNumericIndexer3_es2015.2.minified.js @@ -0,0 +1,2 @@ +var Generics; +Generics || (Generics = {}); diff --git a/crates/swc/tests/tsc-references/subtypingWithNumericIndexer4_es2015.2.minified.js b/crates/swc/tests/tsc-references/subtypingWithNumericIndexer4_es2015.2.minified.js new file mode 100644 index 00000000000..4558588552f --- /dev/null +++ b/crates/swc/tests/tsc-references/subtypingWithNumericIndexer4_es2015.2.minified.js @@ -0,0 +1,2 @@ +var Generics; +Generics || (Generics = {}); diff --git a/crates/swc/tests/tsc-references/subtypingWithNumericIndexer5_es2015.2.minified.js b/crates/swc/tests/tsc-references/subtypingWithNumericIndexer5_es2015.2.minified.js new file mode 100644 index 00000000000..4558588552f --- /dev/null +++ b/crates/swc/tests/tsc-references/subtypingWithNumericIndexer5_es2015.2.minified.js @@ -0,0 +1,2 @@ +var Generics; +Generics || (Generics = {}); diff --git a/crates/swc/tests/tsc-references/subtypingWithNumericIndexer_es2015.2.minified.js b/crates/swc/tests/tsc-references/subtypingWithNumericIndexer_es2015.2.minified.js new file mode 100644 index 00000000000..4558588552f --- /dev/null +++ b/crates/swc/tests/tsc-references/subtypingWithNumericIndexer_es2015.2.minified.js @@ -0,0 +1,2 @@ +var Generics; +Generics || (Generics = {}); diff --git a/crates/swc/tests/tsc-references/subtypingWithObjectMembers5_es2015.2.minified.js b/crates/swc/tests/tsc-references/subtypingWithObjectMembers5_es2015.2.minified.js new file mode 100644 index 00000000000..f021c91d4e8 --- /dev/null +++ b/crates/swc/tests/tsc-references/subtypingWithObjectMembers5_es2015.2.minified.js @@ -0,0 +1,2 @@ +var NotOptional, Optional; +NotOptional || (NotOptional = {}), Optional || (Optional = {}); diff --git a/crates/swc/tests/tsc-references/subtypingWithObjectMembersAccessibility2_es2015.2.minified.js b/crates/swc/tests/tsc-references/subtypingWithObjectMembersAccessibility2_es2015.2.minified.js new file mode 100644 index 00000000000..c7518057bf2 --- /dev/null +++ b/crates/swc/tests/tsc-references/subtypingWithObjectMembersAccessibility2_es2015.2.minified.js @@ -0,0 +1,2 @@ +var ExplicitPublic, ImplicitPublic; +ExplicitPublic || (ExplicitPublic = {}), ImplicitPublic || (ImplicitPublic = {}); diff --git a/crates/swc/tests/tsc-references/subtypingWithObjectMembersOptionality_es2015.2.minified.js b/crates/swc/tests/tsc-references/subtypingWithObjectMembersOptionality_es2015.2.minified.js new file mode 100644 index 00000000000..14614c1ccd1 --- /dev/null +++ b/crates/swc/tests/tsc-references/subtypingWithObjectMembersOptionality_es2015.2.minified.js @@ -0,0 +1,2 @@ +var TwoLevels; +TwoLevels || (TwoLevels = {}); diff --git a/crates/swc/tests/tsc-references/subtypingWithObjectMembersOptionality_es5.2.minified.js b/crates/swc/tests/tsc-references/subtypingWithObjectMembersOptionality_es5.2.minified.js new file mode 100644 index 00000000000..14614c1ccd1 --- /dev/null +++ b/crates/swc/tests/tsc-references/subtypingWithObjectMembersOptionality_es5.2.minified.js @@ -0,0 +1,2 @@ +var TwoLevels; +TwoLevels || (TwoLevels = {}); diff --git a/crates/swc/tests/tsc-references/subtypingWithObjectMembers_es2015.2.minified.js b/crates/swc/tests/tsc-references/subtypingWithObjectMembers_es2015.2.minified.js new file mode 100644 index 00000000000..14614c1ccd1 --- /dev/null +++ b/crates/swc/tests/tsc-references/subtypingWithObjectMembers_es2015.2.minified.js @@ -0,0 +1,2 @@ +var TwoLevels; +TwoLevels || (TwoLevels = {}); diff --git a/crates/swc/tests/tsc-references/subtypingWithStringIndexer3_es2015.2.minified.js b/crates/swc/tests/tsc-references/subtypingWithStringIndexer3_es2015.2.minified.js new file mode 100644 index 00000000000..4558588552f --- /dev/null +++ b/crates/swc/tests/tsc-references/subtypingWithStringIndexer3_es2015.2.minified.js @@ -0,0 +1,2 @@ +var Generics; +Generics || (Generics = {}); diff --git a/crates/swc/tests/tsc-references/subtypingWithStringIndexer4_es2015.2.minified.js b/crates/swc/tests/tsc-references/subtypingWithStringIndexer4_es2015.2.minified.js new file mode 100644 index 00000000000..4558588552f --- /dev/null +++ b/crates/swc/tests/tsc-references/subtypingWithStringIndexer4_es2015.2.minified.js @@ -0,0 +1,2 @@ +var Generics; +Generics || (Generics = {}); diff --git a/crates/swc/tests/tsc-references/subtypingWithStringIndexer_es2015.2.minified.js b/crates/swc/tests/tsc-references/subtypingWithStringIndexer_es2015.2.minified.js new file mode 100644 index 00000000000..4558588552f --- /dev/null +++ b/crates/swc/tests/tsc-references/subtypingWithStringIndexer_es2015.2.minified.js @@ -0,0 +1,2 @@ +var Generics; +Generics || (Generics = {}); diff --git a/crates/swc/tests/tsc-references/superInStaticMembers1_es2015.2.minified.js b/crates/swc/tests/tsc-references/superInStaticMembers1_es2015.2.minified.js index a62e5a5cf26..43d1debac27 100644 --- a/crates/swc/tests/tsc-references/superInStaticMembers1_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/superInStaticMembers1_es2015.2.minified.js @@ -2,6 +2,7 @@ import * as swcHelpers from "@swc/helpers"; export class Reflect { } export var Baz; +!function(Baz) {}(Baz || (Baz = {})); class _class { } class C extends B { diff --git a/crates/swc/tests/tsc-references/superInStaticMembers1_es5.2.minified.js b/crates/swc/tests/tsc-references/superInStaticMembers1_es5.2.minified.js index 978e0982777..76f331d17dd 100644 --- a/crates/swc/tests/tsc-references/superInStaticMembers1_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/superInStaticMembers1_es5.2.minified.js @@ -6,6 +6,7 @@ export var Reflect = function() { swcHelpers.classCallCheck(this, Reflect); }; export var Baz; +!function(Baz) {}(Baz || (Baz = {})); var _class = function() { "use strict"; swcHelpers.classCallCheck(this, _class); @@ -31,19 +32,31 @@ C._ = [ swcHelpers.get(swcHelpers.getPrototypeOf(C), "w", C).call(C); }(), void swcHelpers.get(swcHelpers.getPrototypeOf(C), "w", C).call(C), - void swcHelpers.get(swcHelpers.getPrototypeOf(C), "w", C).call(C), - void swcHelpers.get(swcHelpers.getPrototypeOf(C), "w", C).call(C), + function() { + var Reflect2; + Reflect2 || (Reflect2 = {}), swcHelpers.get(swcHelpers.getPrototypeOf(C), "w", C).call(C); + }(), + function() { + var Reflect3; + Reflect3 || (Reflect3 = {}), swcHelpers.get(swcHelpers.getPrototypeOf(C), "w", C).call(C); + }(), void swcHelpers.get(swcHelpers.getPrototypeOf(C), "w", C).call(C), void swcHelpers.get(swcHelpers.getPrototypeOf(C), "w", C).call(C), void swcHelpers.get(swcHelpers.getPrototypeOf(C), "w", C).call(C), void swcHelpers.get(swcHelpers.getPrototypeOf(C), "w", C).call(C), ], _superprop_get_w().call(_this), _superprop_get_w().call(_this), _superprop_get_w().call(_this), function() { - var Reflect2 = function() { + var Reflect4 = function() { "use strict"; - swcHelpers.classCallCheck(this, Reflect2); + swcHelpers.classCallCheck(this, Reflect4); }; _superprop_get_w().call(_this); -}(), _superprop_get_w().call(_this), _superprop_get_w().call(_this), _superprop_get_w().call(_this), _superprop_get_w().call(_this), _superprop_get_w().call(_this), _superprop_get_w().call(_this), _superprop_get_w().call(_this); +}(), _superprop_get_w().call(_this), function() { + var Reflect5; + Reflect5 || (Reflect5 = {}), _superprop_get_w().call(_this); +}(), function() { + var Reflect6; + Reflect6 || (Reflect6 = {}), _superprop_get_w().call(_this); +}(), _superprop_get_w().call(_this), _superprop_get_w().call(_this), _superprop_get_w().call(_this), _superprop_get_w().call(_this); var Reflect = null, C = function(B) { "use strict"; swcHelpers.inherits(C, B); @@ -171,7 +184,7 @@ var C = function(B) { } return C; }(B); -_superprop_get_w().call(_this); +_superprop_get_w().call(_this), Reflect = {}; var C = function(B) { "use strict"; swcHelpers.inherits(C, B); @@ -181,7 +194,27 @@ var C = function(B) { } return C; }(B); -C._ = swcHelpers.get(swcHelpers.getPrototypeOf(C), "w", C).call(C); +C._ = swcHelpers.get(swcHelpers.getPrototypeOf(C), "w", C).call(C), Reflect = {}; +var C = function(B) { + "use strict"; + swcHelpers.inherits(C, B); + var _super = swcHelpers.createSuper(C); + function C() { + return swcHelpers.classCallCheck(this, C), _super.apply(this, arguments); + } + return C; +}(B); +_superprop_get_w().call(_this), Reflect = {}; +var C = function(B) { + "use strict"; + swcHelpers.inherits(C, B); + var _super = swcHelpers.createSuper(C); + function C() { + return swcHelpers.classCallCheck(this, C), _super.apply(this, arguments); + } + return C; +}(B); +C._ = swcHelpers.get(swcHelpers.getPrototypeOf(C), "w", C).call(C), Reflect = {}; var C = function(B) { "use strict"; swcHelpers.inherits(C, B); @@ -431,29 +464,9 @@ var C = function(B) { } return C; }(B); -_superprop_get_w().call(_this); -var C = function(B) { +_superprop_get_w().call(_this), _$_Reflect = function Reflect7() { "use strict"; - swcHelpers.inherits(C, B); - var _super = swcHelpers.createSuper(C); - function C() { - return swcHelpers.classCallCheck(this, C), _super.apply(this, arguments); - } - return C; -}(B); -C._ = swcHelpers.get(swcHelpers.getPrototypeOf(C), "w", C).call(C); -var C = function(B) { - "use strict"; - swcHelpers.inherits(C, B); - var _super = swcHelpers.createSuper(C); - function C() { - return swcHelpers.classCallCheck(this, C), _super.apply(this, arguments); - } - return C; -}(B); -_superprop_get_w().call(_this), _$_Reflect = function Reflect3() { - "use strict"; - swcHelpers.classCallCheck(this, Reflect3); + swcHelpers.classCallCheck(this, Reflect7); }, _$__ = { writable: !0, value: function() { @@ -468,9 +481,9 @@ _superprop_get_w().call(_this), _$_Reflect = function Reflect3() { }(B); C._ = swcHelpers.get(swcHelpers.getPrototypeOf(C), "w", C).call(C); }() -}, _$_Reflect = function Reflect4() { +}, _$_Reflect = function Reflect8() { "use strict"; - swcHelpers.classCallCheck(this, Reflect4); + swcHelpers.classCallCheck(this, Reflect8); }, _$__ = { writable: !0, value: function() { diff --git a/crates/swc/tests/tsc-references/symbolProperty50_es2015.2.minified.js b/crates/swc/tests/tsc-references/symbolProperty50_es2015.2.minified.js new file mode 100644 index 00000000000..cf77a4b72fa --- /dev/null +++ b/crates/swc/tests/tsc-references/symbolProperty50_es2015.2.minified.js @@ -0,0 +1,2 @@ +var M; +M || (M = {}); diff --git a/crates/swc/tests/tsc-references/symbolType19_es2015.2.minified.js b/crates/swc/tests/tsc-references/symbolType19_es2015.2.minified.js index e69de29bb2d..651e5b2b096 100644 --- a/crates/swc/tests/tsc-references/symbolType19_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolType19_es2015.2.minified.js @@ -0,0 +1,2 @@ +var E; +!function(E) {}(E || (E = {})); diff --git a/crates/swc/tests/tsc-references/symbolType19_es5.2.minified.js b/crates/swc/tests/tsc-references/symbolType19_es5.2.minified.js index e69de29bb2d..651e5b2b096 100644 --- a/crates/swc/tests/tsc-references/symbolType19_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolType19_es5.2.minified.js @@ -0,0 +1,2 @@ +var E; +!function(E) {}(E || (E = {})); diff --git a/crates/swc/tests/tsc-references/taggedTemplateStringsTypeArgumentInferenceES6_es5.2.minified.js b/crates/swc/tests/tsc-references/taggedTemplateStringsTypeArgumentInferenceES6_es5.2.minified.js index 1972e07d92b..68f381a992d 100644 --- a/crates/swc/tests/tsc-references/taggedTemplateStringsTypeArgumentInferenceES6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/taggedTemplateStringsTypeArgumentInferenceES6_es5.2.minified.js @@ -1,7 +1,6 @@ import * as swcHelpers from "@swc/helpers"; function _templateObject() { var data = swcHelpers.taggedTemplateLiteral([ - "", "" ]); return _templateObject = function _templateObject() { @@ -10,7 +9,6 @@ function _templateObject() { } function _templateObject1() { var data = swcHelpers.taggedTemplateLiteral([ - "", "" ]); return _templateObject1 = function _templateObject1() { @@ -46,7 +44,6 @@ function _templateObject4() { } function _templateObject5() { var data = swcHelpers.taggedTemplateLiteral([ - "", "", "" ]); @@ -56,7 +53,6 @@ function _templateObject5() { } function _templateObject6() { var data = swcHelpers.taggedTemplateLiteral([ - "", "", "" ]); @@ -66,7 +62,6 @@ function _templateObject6() { } function _templateObject7() { var data = swcHelpers.taggedTemplateLiteral([ - "", "", "" ]); @@ -77,7 +72,6 @@ function _templateObject7() { function _templateObject8() { var data = swcHelpers.taggedTemplateLiteral([ "", - " ", "" ]); return _templateObject8 = function _templateObject8() { @@ -106,7 +100,6 @@ function _templateObject10() { } function _templateObject11() { var data = swcHelpers.taggedTemplateLiteral([ - "", "", "", "" @@ -118,8 +111,7 @@ function _templateObject11() { function _templateObject12() { var data = swcHelpers.taggedTemplateLiteral([ "", - "", - "", + " ", "" ]); return _templateObject12 = function _templateObject12() { @@ -128,7 +120,6 @@ function _templateObject12() { } function _templateObject13() { var data = swcHelpers.taggedTemplateLiteral([ - "", "", "", "" @@ -139,7 +130,6 @@ function _templateObject13() { } function _templateObject14() { var data = swcHelpers.taggedTemplateLiteral([ - "", "", "", "" @@ -172,6 +162,8 @@ function _templateObject16() { } function _templateObject17() { var data = swcHelpers.taggedTemplateLiteral([ + "", + "", "", "" ]); @@ -214,8 +206,6 @@ function _templateObject20() { } function _templateObject21() { var data = swcHelpers.taggedTemplateLiteral([ - "", - "", "", "" ]); @@ -245,59 +235,101 @@ function _templateObject23() { return data; }, data; } +function _templateObject24() { + var data = swcHelpers.taggedTemplateLiteral([ + "", + "", + "", + "" + ]); + return _templateObject24 = function _templateObject24() { + return data; + }, data; +} +function _templateObject25() { + var data = swcHelpers.taggedTemplateLiteral([ + "", + "", + "", + "" + ]); + return _templateObject25 = function _templateObject25() { + return data; + }, data; +} +function _templateObject26() { + var data = swcHelpers.taggedTemplateLiteral([ + "", + "", + "", + "" + ]); + return _templateObject26 = function _templateObject26() { + return data; + }, data; +} +function _templateObject27() { + var data = swcHelpers.taggedTemplateLiteral([ + "", + "", + "", + "" + ]); + return _templateObject27 = function _templateObject27() { + return data; + }, data; +} function someGenerics3(strs, producer) {} function someGenerics4(strs, n, f) {} function someGenerics5(strs, n, f) {} function someGenerics6(strs, a, b, c) {} function someGenerics7(strs, a, b, c) {} -!function(strs, n) {}(_templateObject(), function(n) { - return n; -}), _templateObject1(), someGenerics3(_templateObject2(), function() { +_templateObject(), _templateObject1(), _templateObject2(), _templateObject3(), _templateObject4(), _templateObject5(), someGenerics3(_templateObject6(), function() { return ""; -}), someGenerics3(_templateObject3(), function() {}), someGenerics3(_templateObject4(), function() { +}), someGenerics3(_templateObject7(), function() {}), someGenerics3(_templateObject8(), function() { return 3; -}), someGenerics4(_templateObject5(), 4, function() { +}), someGenerics4(_templateObject9(), 4, function() { return null; -}), someGenerics4(_templateObject6(), "", function() { +}), someGenerics4(_templateObject10(), "", function() { return 3; -}), someGenerics4(_templateObject7(), null, null), someGenerics5(_templateObject8(), 4, function() { +}), someGenerics4(_templateObject11(), null, null), someGenerics5(_templateObject12(), 4, function() { return null; -}), someGenerics5(_templateObject9(), "", function() { +}), someGenerics5(_templateObject13(), "", function() { return 3; -}), someGenerics5(_templateObject10(), null, null), someGenerics6(_templateObject11(), function(n) { +}), someGenerics5(_templateObject14(), null, null), someGenerics6(_templateObject15(), function(n) { return n; }, function(n) { return n; }, function(n) { return n; -}), someGenerics6(_templateObject12(), function(n) { +}), someGenerics6(_templateObject16(), function(n) { return n; }, function(n) { return n; }, function(n) { return n; -}), someGenerics6(_templateObject13(), function(n) { +}), someGenerics6(_templateObject17(), function(n) { return n; }, function(n) { return n; }, function(n) { return n; -}), someGenerics7(_templateObject14(), function(n) { +}), someGenerics7(_templateObject18(), function(n) { return n; }, function(n) { return n; }, function(n) { return n; -}), someGenerics7(_templateObject15(), function(n) { +}), someGenerics7(_templateObject19(), function(n) { return n; }, function(n) { return n; }, function(n) { return n; -}), someGenerics7(_templateObject16(), function(n) { +}), someGenerics7(_templateObject20(), function(n) { return n; }, function(n) { return n; }, function(n) { return n; -}), (_templateObject17(), someGenerics7)(_templateObject18(), null, null, null), _templateObject19(), _templateObject20(), _templateObject21(), _templateObject22(), _templateObject23(); +}), (_templateObject21(), someGenerics7)(_templateObject22(), null, null, null), _templateObject23(), _templateObject24(), _templateObject25(), _templateObject26(), _templateObject27(); diff --git a/crates/swc/tests/tsc-references/taggedTemplateStringsTypeArgumentInference_es5.2.minified.js b/crates/swc/tests/tsc-references/taggedTemplateStringsTypeArgumentInference_es5.2.minified.js index 1972e07d92b..68f381a992d 100644 --- a/crates/swc/tests/tsc-references/taggedTemplateStringsTypeArgumentInference_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/taggedTemplateStringsTypeArgumentInference_es5.2.minified.js @@ -1,7 +1,6 @@ import * as swcHelpers from "@swc/helpers"; function _templateObject() { var data = swcHelpers.taggedTemplateLiteral([ - "", "" ]); return _templateObject = function _templateObject() { @@ -10,7 +9,6 @@ function _templateObject() { } function _templateObject1() { var data = swcHelpers.taggedTemplateLiteral([ - "", "" ]); return _templateObject1 = function _templateObject1() { @@ -46,7 +44,6 @@ function _templateObject4() { } function _templateObject5() { var data = swcHelpers.taggedTemplateLiteral([ - "", "", "" ]); @@ -56,7 +53,6 @@ function _templateObject5() { } function _templateObject6() { var data = swcHelpers.taggedTemplateLiteral([ - "", "", "" ]); @@ -66,7 +62,6 @@ function _templateObject6() { } function _templateObject7() { var data = swcHelpers.taggedTemplateLiteral([ - "", "", "" ]); @@ -77,7 +72,6 @@ function _templateObject7() { function _templateObject8() { var data = swcHelpers.taggedTemplateLiteral([ "", - " ", "" ]); return _templateObject8 = function _templateObject8() { @@ -106,7 +100,6 @@ function _templateObject10() { } function _templateObject11() { var data = swcHelpers.taggedTemplateLiteral([ - "", "", "", "" @@ -118,8 +111,7 @@ function _templateObject11() { function _templateObject12() { var data = swcHelpers.taggedTemplateLiteral([ "", - "", - "", + " ", "" ]); return _templateObject12 = function _templateObject12() { @@ -128,7 +120,6 @@ function _templateObject12() { } function _templateObject13() { var data = swcHelpers.taggedTemplateLiteral([ - "", "", "", "" @@ -139,7 +130,6 @@ function _templateObject13() { } function _templateObject14() { var data = swcHelpers.taggedTemplateLiteral([ - "", "", "", "" @@ -172,6 +162,8 @@ function _templateObject16() { } function _templateObject17() { var data = swcHelpers.taggedTemplateLiteral([ + "", + "", "", "" ]); @@ -214,8 +206,6 @@ function _templateObject20() { } function _templateObject21() { var data = swcHelpers.taggedTemplateLiteral([ - "", - "", "", "" ]); @@ -245,59 +235,101 @@ function _templateObject23() { return data; }, data; } +function _templateObject24() { + var data = swcHelpers.taggedTemplateLiteral([ + "", + "", + "", + "" + ]); + return _templateObject24 = function _templateObject24() { + return data; + }, data; +} +function _templateObject25() { + var data = swcHelpers.taggedTemplateLiteral([ + "", + "", + "", + "" + ]); + return _templateObject25 = function _templateObject25() { + return data; + }, data; +} +function _templateObject26() { + var data = swcHelpers.taggedTemplateLiteral([ + "", + "", + "", + "" + ]); + return _templateObject26 = function _templateObject26() { + return data; + }, data; +} +function _templateObject27() { + var data = swcHelpers.taggedTemplateLiteral([ + "", + "", + "", + "" + ]); + return _templateObject27 = function _templateObject27() { + return data; + }, data; +} function someGenerics3(strs, producer) {} function someGenerics4(strs, n, f) {} function someGenerics5(strs, n, f) {} function someGenerics6(strs, a, b, c) {} function someGenerics7(strs, a, b, c) {} -!function(strs, n) {}(_templateObject(), function(n) { - return n; -}), _templateObject1(), someGenerics3(_templateObject2(), function() { +_templateObject(), _templateObject1(), _templateObject2(), _templateObject3(), _templateObject4(), _templateObject5(), someGenerics3(_templateObject6(), function() { return ""; -}), someGenerics3(_templateObject3(), function() {}), someGenerics3(_templateObject4(), function() { +}), someGenerics3(_templateObject7(), function() {}), someGenerics3(_templateObject8(), function() { return 3; -}), someGenerics4(_templateObject5(), 4, function() { +}), someGenerics4(_templateObject9(), 4, function() { return null; -}), someGenerics4(_templateObject6(), "", function() { +}), someGenerics4(_templateObject10(), "", function() { return 3; -}), someGenerics4(_templateObject7(), null, null), someGenerics5(_templateObject8(), 4, function() { +}), someGenerics4(_templateObject11(), null, null), someGenerics5(_templateObject12(), 4, function() { return null; -}), someGenerics5(_templateObject9(), "", function() { +}), someGenerics5(_templateObject13(), "", function() { return 3; -}), someGenerics5(_templateObject10(), null, null), someGenerics6(_templateObject11(), function(n) { +}), someGenerics5(_templateObject14(), null, null), someGenerics6(_templateObject15(), function(n) { return n; }, function(n) { return n; }, function(n) { return n; -}), someGenerics6(_templateObject12(), function(n) { +}), someGenerics6(_templateObject16(), function(n) { return n; }, function(n) { return n; }, function(n) { return n; -}), someGenerics6(_templateObject13(), function(n) { +}), someGenerics6(_templateObject17(), function(n) { return n; }, function(n) { return n; }, function(n) { return n; -}), someGenerics7(_templateObject14(), function(n) { +}), someGenerics7(_templateObject18(), function(n) { return n; }, function(n) { return n; }, function(n) { return n; -}), someGenerics7(_templateObject15(), function(n) { +}), someGenerics7(_templateObject19(), function(n) { return n; }, function(n) { return n; }, function(n) { return n; -}), someGenerics7(_templateObject16(), function(n) { +}), someGenerics7(_templateObject20(), function(n) { return n; }, function(n) { return n; }, function(n) { return n; -}), (_templateObject17(), someGenerics7)(_templateObject18(), null, null, null), _templateObject19(), _templateObject20(), _templateObject21(), _templateObject22(), _templateObject23(); +}), (_templateObject21(), someGenerics7)(_templateObject22(), null, null, null), _templateObject23(), _templateObject24(), _templateObject25(), _templateObject26(), _templateObject27(); diff --git a/crates/swc/tests/tsc-references/tsxEmit3_es2015.2.minified.js b/crates/swc/tests/tsc-references/tsxEmit3_es2015.2.minified.js index 367148b0361..a1ce31fa5c1 100644 --- a/crates/swc/tests/tsc-references/tsxEmit3_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxEmit3_es2015.2.minified.js @@ -4,4 +4,6 @@ var M; constructor(){} }, (M1.S || (M1.S = {})).Bar = class { }; -}(M || (M = {})), M || (M = {}), S.Bar, S.Bar; +}(M || (M = {})), function(M2) { + M2.S || (M2.S = {}); +}(M || (M = {})), M || (M = {}), S.Bar, S.Bar, M || (M = {}); diff --git a/crates/swc/tests/tsc-references/tsxEmit3_es5.2.minified.js b/crates/swc/tests/tsc-references/tsxEmit3_es5.2.minified.js index 1dcbc4cc4b8..d9050c1aa7a 100644 --- a/crates/swc/tests/tsc-references/tsxEmit3_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxEmit3_es5.2.minified.js @@ -9,4 +9,6 @@ import * as swcHelpers from "@swc/helpers"; "use strict"; swcHelpers.classCallCheck(this, Bar); }, S.Bar = Bar; -}(M || (M = {})), M || (M = {}), S.Bar, S.Bar; +}(M || (M = {})), function(M2) { + M2.S || (M2.S = {}); +}(M || (M = {})), M || (M = {}), S.Bar, S.Bar, M || (M = {}); diff --git a/crates/swc/tests/tsc-references/typeGuardEnums_es2015.2.minified.js b/crates/swc/tests/tsc-references/typeGuardEnums_es2015.2.minified.js index e69de29bb2d..651e5b2b096 100644 --- a/crates/swc/tests/tsc-references/typeGuardEnums_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/typeGuardEnums_es2015.2.minified.js @@ -0,0 +1,2 @@ +var E; +!function(E) {}(E || (E = {})); diff --git a/crates/swc/tests/tsc-references/typeGuardEnums_es5.2.minified.js b/crates/swc/tests/tsc-references/typeGuardEnums_es5.2.minified.js index e69de29bb2d..651e5b2b096 100644 --- a/crates/swc/tests/tsc-references/typeGuardEnums_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/typeGuardEnums_es5.2.minified.js @@ -0,0 +1,2 @@ +var E; +!function(E) {}(E || (E = {})); diff --git a/crates/swc/tests/tsc-references/typeOfThisInFunctionExpression_es2015.2.minified.js b/crates/swc/tests/tsc-references/typeOfThisInFunctionExpression_es2015.2.minified.js new file mode 100644 index 00000000000..cf77a4b72fa --- /dev/null +++ b/crates/swc/tests/tsc-references/typeOfThisInFunctionExpression_es2015.2.minified.js @@ -0,0 +1,2 @@ +var M; +M || (M = {}); diff --git a/crates/swc/tests/tsc-references/typeOfThisInFunctionExpression_es5.2.minified.js b/crates/swc/tests/tsc-references/typeOfThisInFunctionExpression_es5.2.minified.js index 36a040c8150..e06d57971e1 100644 --- a/crates/swc/tests/tsc-references/typeOfThisInFunctionExpression_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/typeOfThisInFunctionExpression_es5.2.minified.js @@ -1,5 +1,6 @@ import * as swcHelpers from "@swc/helpers"; -var C = function() { +var M, C = function() { "use strict"; swcHelpers.classCallCheck(this, C), this.x = function() {}, this.y = function() {}; }; +M || (M = {}); diff --git a/crates/swc/tests/tsc-references/typeofModuleWithoutExports_es2015.2.minified.js b/crates/swc/tests/tsc-references/typeofModuleWithoutExports_es2015.2.minified.js new file mode 100644 index 00000000000..cf77a4b72fa --- /dev/null +++ b/crates/swc/tests/tsc-references/typeofModuleWithoutExports_es2015.2.minified.js @@ -0,0 +1,2 @@ +var M; +M || (M = {}); diff --git a/crates/swc/tests/tsc-references/typeofOperatorWithEnumType_es2015.2.minified.js b/crates/swc/tests/tsc-references/typeofOperatorWithEnumType_es2015.2.minified.js index c493ff84ea3..dd2e59dbd7e 100644 --- a/crates/swc/tests/tsc-references/typeofOperatorWithEnumType_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/typeofOperatorWithEnumType_es2015.2.minified.js @@ -1,4 +1,4 @@ var ENUM, ENUM1; -!function(ENUM1) { +!function(ENUM) {}(ENUM || (ENUM = {})), function(ENUM1) { ENUM1[ENUM1.A = 0] = "A", ENUM1[ENUM1.B = 1] = "B", ENUM1[ENUM1[""] = 2] = ""; }(ENUM1 || (ENUM1 = {})), ENUM1.A, ENUM[0], ENUM1.B, ENUM[0], ENUM1.B, ENUM1.B; diff --git a/crates/swc/tests/tsc-references/typeofOperatorWithEnumType_es5.2.minified.js b/crates/swc/tests/tsc-references/typeofOperatorWithEnumType_es5.2.minified.js index ff38dda6a0e..ebaeb038ecd 100644 --- a/crates/swc/tests/tsc-references/typeofOperatorWithEnumType_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/typeofOperatorWithEnumType_es5.2.minified.js @@ -1,6 +1,6 @@ var ENUM, ENUM1; import * as swcHelpers from "@swc/helpers"; -!function(ENUM1) { +!function(ENUM) {}(ENUM || (ENUM = {})), function(ENUM1) { ENUM1[ENUM1.A = 0] = "A", ENUM1[ENUM1.B = 1] = "B", ENUM1[ENUM1[""] = 2] = ""; }(ENUM1 || (ENUM1 = {})), void 0 === ENUM || swcHelpers.typeOf(ENUM), void 0 === ENUM1 || swcHelpers.typeOf(ENUM1), swcHelpers.typeOf(ENUM1.A), swcHelpers.typeOf(ENUM[0] + ENUM1.B), swcHelpers.typeOf(void 0 === ENUM ? "undefined" : swcHelpers.typeOf(ENUM)), swcHelpers.typeOf(swcHelpers.typeOf(swcHelpers.typeOf(ENUM[0] + ENUM1.B))), void 0 === ENUM || swcHelpers.typeOf(ENUM), void 0 === ENUM1 || swcHelpers.typeOf(ENUM1), swcHelpers.typeOf(ENUM1.B), void 0 === ENUM || swcHelpers.typeOf(ENUM); z: void 0 === ENUM || swcHelpers.typeOf(ENUM); diff --git a/crates/swc/tests/tsc-references/voidOperatorWithEnumType_es2015.2.minified.js b/crates/swc/tests/tsc-references/voidOperatorWithEnumType_es2015.2.minified.js index c493ff84ea3..dd2e59dbd7e 100644 --- a/crates/swc/tests/tsc-references/voidOperatorWithEnumType_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/voidOperatorWithEnumType_es2015.2.minified.js @@ -1,4 +1,4 @@ var ENUM, ENUM1; -!function(ENUM1) { +!function(ENUM) {}(ENUM || (ENUM = {})), function(ENUM1) { ENUM1[ENUM1.A = 0] = "A", ENUM1[ENUM1.B = 1] = "B", ENUM1[ENUM1[""] = 2] = ""; }(ENUM1 || (ENUM1 = {})), ENUM1.A, ENUM[0], ENUM1.B, ENUM[0], ENUM1.B, ENUM1.B; diff --git a/crates/swc/tests/tsc-references/voidOperatorWithEnumType_es5.2.minified.js b/crates/swc/tests/tsc-references/voidOperatorWithEnumType_es5.2.minified.js index c493ff84ea3..dd2e59dbd7e 100644 --- a/crates/swc/tests/tsc-references/voidOperatorWithEnumType_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/voidOperatorWithEnumType_es5.2.minified.js @@ -1,4 +1,4 @@ var ENUM, ENUM1; -!function(ENUM1) { +!function(ENUM) {}(ENUM || (ENUM = {})), function(ENUM1) { ENUM1[ENUM1.A = 0] = "A", ENUM1[ENUM1.B = 1] = "B", ENUM1[ENUM1[""] = 2] = ""; }(ENUM1 || (ENUM1 = {})), ENUM1.A, ENUM[0], ENUM1.B, ENUM[0], ENUM1.B, ENUM1.B; diff --git a/crates/swc_ecma_minifier/Cargo.toml b/crates/swc_ecma_minifier/Cargo.toml index 6d9020b490e..91ebbe8a4d1 100644 --- a/crates/swc_ecma_minifier/Cargo.toml +++ b/crates/swc_ecma_minifier/Cargo.toml @@ -18,6 +18,7 @@ bench = false [features] debug = ["backtrace", "swc_ecma_transforms_optimization/debug"] +trace-ast = [] [dependencies] ahash = "0.7.6" diff --git a/crates/swc_ecma_minifier/scripts/exec.sh b/crates/swc_ecma_minifier/scripts/exec.sh new file mode 100755 index 00000000000..3b77f1dd8c5 --- /dev/null +++ b/crates/swc_ecma_minifier/scripts/exec.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -eu + + +export RUST_LOG=trace +export SWC_CHECK=1 + +cargo test --test terser_exec --features debug $@ diff --git a/crates/swc_ecma_minifier/src/compress/mod.rs b/crates/swc_ecma_minifier/src/compress/mod.rs index d8e1d790c60..314c8486159 100644 --- a/crates/swc_ecma_minifier/src/compress/mod.rs +++ b/crates/swc_ecma_minifier/src/compress/mod.rs @@ -202,8 +202,6 @@ where } loop { - n.invoke(); - self.changed = false; self.optimize_unit(n); self.pass += 1; @@ -282,10 +280,9 @@ where let mut visitor = expr_simplifier(ExprSimplifierConfig {}); n.apply(&mut visitor); + self.changed |= visitor.changed(); if visitor.changed() { - n.invoke(); - debug!("compressor: Simplified expressions"); if cfg!(feature = "debug") { debug!("===== Simplified =====\n{}", dump(&*n, false)); @@ -327,11 +324,8 @@ where self.pass >= 20, ); n.apply(&mut visitor); - self.changed |= visitor.changed(); - if visitor.changed() { - n.invoke(); - } + self.changed |= visitor.changed(); if cfg!(feature = "debug") && visitor.changed() { let src = n.dump(); @@ -361,10 +355,6 @@ where ); n.apply(&mut visitor); - if visitor.changed() { - n.invoke(); - } - self.changed |= visitor.changed(); // let done = dump(&*n); @@ -383,10 +373,6 @@ where let mut v = dead_branch_remover(); n.apply(&mut v); - if v.changed() { - n.invoke(); - } - if let Some(start_time) = start_time { let end_time = Instant::now(); diff --git a/crates/swc_ecma_minifier/src/compress/optimize/iife.rs b/crates/swc_ecma_minifier/src/compress/optimize/iife.rs index ae249ad28c9..71e03f691d4 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/iife.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/iife.rs @@ -232,6 +232,10 @@ where } } } + if vars.is_empty() { + log_abort!("vars is empty"); + return; + } let ctx = Ctx { in_fn_like: true, @@ -506,7 +510,9 @@ where } let body = f.function.body.as_mut().unwrap(); - if body.stmts.is_empty() { + if body.stmts.is_empty() && call.args.is_empty() { + self.changed = true; + report_change!("iife: Inlining an empty function call as `undefined`"); *e = *undefined(f.function.span); return; } diff --git a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs index 6a65073cf21..d6fca503fe9 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs @@ -779,6 +779,9 @@ where if self.options.reduce_vars && self.options.side_effects { if let Some(usage) = self.data.vars.get(&callee.to_id()) { if !usage.reassigned() && usage.pure_fn { + self.changed = true; + report_change!("Reducing funcion call to a variable"); + let args = args .take() .into_iter() @@ -910,7 +913,13 @@ where PropName::BigInt(_) => {} }, - Prop::Shorthand(_) | Prop::Assign(..) => {} + Prop::Assign(mut prop) => { + exprs.extend( + self.ignore_return_value(&mut prop.value).map(Box::new), + ); + } + + Prop::Shorthand(_) => {} }, } } @@ -1708,14 +1717,33 @@ where n.visit_mut_children_with(&mut *self.with_ctx(ctx)); } - #[cfg_attr(feature = "debug", tracing::instrument(skip_all))] fn visit_mut_expr(&mut self, e: &mut Expr) { + #[cfg(feature = "trace-ast")] + let _tracing = { + let s = dump(&*e, true); + tracing::span!( + tracing::Level::ERROR, + "visit_mut_expr", + src = tracing::field::display(&s) + ) + .entered() + }; let ctx = Ctx { is_exported: false, is_callee: false, ..self.ctx }; e.visit_mut_children_with(&mut *self.with_ctx(ctx)); + #[cfg(feature = "trace-ast")] + let _tracing = { + let s = dump(&*e, true); + tracing::span!( + tracing::Level::ERROR, + "visit_mut_expr_after_children", + src = tracing::field::display(&s) + ) + .entered() + }; match e { Expr::Seq(seq) if seq.exprs.len() == 1 => { @@ -1778,6 +1806,9 @@ where } _ => {} } + + #[cfg(feature = "trace-ast")] + debug!("Output: {}", dump(e, true)); } #[cfg_attr(feature = "debug", tracing::instrument(skip_all))] @@ -1838,9 +1869,17 @@ where } } } + + #[cfg(feature = "debug")] + let start = dump(&n.expr, true); + let expr = self.ignore_return_value(&mut n.expr); n.expr = expr.map(Box::new).unwrap_or_else(|| { report_change!("visit_mut_expr_stmt: Dropped an expression statement"); + + #[cfg(feature = "debug")] + dump_change_detail!("Removed {}", start); + undefined(DUMMY_SP) }); } else { diff --git a/crates/swc_ecma_minifier/src/compress/pure/mod.rs b/crates/swc_ecma_minifier/src/compress/pure/mod.rs index ee8798da135..f3e7706aa77 100644 --- a/crates/swc_ecma_minifier/src/compress/pure/mod.rs +++ b/crates/swc_ecma_minifier/src/compress/pure/mod.rs @@ -156,7 +156,10 @@ impl Pure<'_> { where N: for<'aa> VisitMutWith> + Send + Sync, { - if self.ctx.par_depth >= MAX_PAR_DEPTH * 2 || cfg!(target_arch = "wasm32") { + if self.ctx.par_depth >= MAX_PAR_DEPTH * 2 + || cfg!(target_arch = "wasm32") + || cfg!(feature = "debug") + { for node in nodes { let mut v = Pure { changed: false, diff --git a/crates/swc_ecma_minifier/src/debug.rs b/crates/swc_ecma_minifier/src/debug.rs index 4bc01d93150..cfbad26f83c 100644 --- a/crates/swc_ecma_minifier/src/debug.rs +++ b/crates/swc_ecma_minifier/src/debug.rs @@ -104,10 +104,10 @@ pub(crate) fn invoke(module: &Module) { emitter.emit_module(&module).unwrap(); } - debug!("Validating with node.js"); - let code = String::from_utf8(buf).unwrap(); + debug!("Validating with node.js:\n{}", code); + if SHOULD_CHECK { let mut child = Command::new("node") .arg("-") diff --git a/crates/swc_ecma_minifier/src/util/unit.rs b/crates/swc_ecma_minifier/src/util/unit.rs index 21e2465fb17..3e3d93e2525 100644 --- a/crates/swc_ecma_minifier/src/util/unit.rs +++ b/crates/swc_ecma_minifier/src/util/unit.rs @@ -33,8 +33,6 @@ pub(crate) trait CompileUnit: V: VisitMut; fn remove_mark(&mut self) -> Mark; - - fn invoke(&self); } impl CompileUnit for Module { @@ -60,18 +58,13 @@ impl CompileUnit for Module { V: VisitMut, { self.visit_mut_with(&mut *visitor); - if cfg!(debug_assertions) { - self.visit_with(&mut AssertValid); - } + + crate::debug::invoke(self); } fn remove_mark(&mut self) -> Mark { Mark::root() } - - fn invoke(&self) { - crate::debug::invoke(self) - } } impl CompileUnit for FnExpr { @@ -105,6 +98,4 @@ impl CompileUnit for FnExpr { fn remove_mark(&mut self) -> Mark { self.function.span.remove_mark() } - - fn invoke(&self) {} } diff --git a/crates/swc_ecma_minifier/tests/TODO.txt b/crates/swc_ecma_minifier/tests/TODO.txt index 72c325a28a3..7a1ab7f51cd 100644 --- a/crates/swc_ecma_minifier/tests/TODO.txt +++ b/crates/swc_ecma_minifier/tests/TODO.txt @@ -61,6 +61,7 @@ evaluate/issue_2535_1/input.js expansions/avoid_spread_getset_object/input.js expansions/avoid_spread_hole/input.js functions/avoid_generating_duplicate_functions_compared_together_3/input.js +functions/empty_body/input.js functions/inline_true/input.js functions/inner_ref/input.js functions/issue_2084/input.js diff --git a/crates/swc_ecma_minifier/tests/golden.txt b/crates/swc_ecma_minifier/tests/golden.txt index e6293f51672..d2b768363ce 100644 --- a/crates/swc_ecma_minifier/tests/golden.txt +++ b/crates/swc_ecma_minifier/tests/golden.txt @@ -527,7 +527,6 @@ functions/drop_lone_use_strict/input.js functions/drop_lone_use_strict_arrows_1/input.js functions/drop_lone_use_strict_arrows_2/input.js functions/duplicate_argnames/input.js -functions/empty_body/input.js functions/function_returning_constant_literal/input.js functions/iifes_returning_constants_keep_fargs_false/input.js functions/iifes_returning_constants_keep_fargs_true/input.js diff --git a/crates/swc_ecma_minifier/tests/terser_exec.rs b/crates/swc_ecma_minifier/tests/terser_exec.rs index 5326157538c..7d6db6befc1 100644 --- a/crates/swc_ecma_minifier/tests/terser_exec.rs +++ b/crates/swc_ecma_minifier/tests/terser_exec.rs @@ -35,7 +35,6 @@ use testing::assert_eq; "tests/terser/compress/**/input.js", exclude( "ie8", - // Temporary "blocks/issue_1672_for/", "collapse_vars/collapse_vars_do_while/", "collapse_vars/collapse_vars_lvalues/", @@ -44,7 +43,6 @@ use testing::assert_eq; "collapse_vars/issue_1631_3/", "dead_code/issue_2749/", "dead_code/try_catch_finally/", - "destructuring/unused_destructuring_getter_side_effect_2/", "drop_unused/drop_toplevel_keep_assign/", "drop_unused/drop_toplevel_retain_regex/", "drop_unused/issue_1715_1/", @@ -57,33 +55,24 @@ use testing::assert_eq; "evaluate/issue_1760_1/", "evaluate/prop_function/", "functions/hoist_funs_strict/", - "functions/issue_2114_1/", - "functions/issue_2114_2/", "functions/issue_2620_4/", "functions/issue_3016_3/", "functions/issue_3076/", "harmony/array_literal_with_spread_4a/", "harmony/array_literal_with_spread_4b/", "harmony/class_extends/", - "hoist_props/contains_this_2/", - "hoist_props/issue_2508_5/", - "hoist_props/issue_2508_6/", "issue_1105/assorted_Infinity_NaN_undefined_in_with_scope/", "issue_1105/assorted_Infinity_NaN_undefined_in_with_scope_keep_infinity/", "issue_1733/function_catch_catch/", "issue_1750/case_1/", "keep_names/keep_some_fnames_reduce/", "properties/issue_3188_3/", - "properties/join_object_assignments_1/", - "properties/mangle_properties_which_matches_pattern/", "properties/unsafe_methods_regex/", - "pure_funcs/issue_3065_3/", - "pure_funcs/issue_3065_4/", "reduce_vars/unsafe_evaluate_modified/", "rename/function_catch_catch/", "sequences/delete_seq_4/", "sequences/delete_seq_5/", - "yield/issue_2689/" + "yield/issue_2689/", ) )] fn terser_exec(input: PathBuf) { @@ -102,6 +91,10 @@ fn terser_exec(input: PathBuf) { return Ok(()); } + let input_stdout = stdout_of(&input_src, Duration::from_millis(500)).map_err(|_| { + eprintln!("This test is not executable test"); + })?; + let expected_src = read_to_string(&dir.join("output.terser.js")).map_err(|_| { eprintln!("This test does not have `output.terser.js`"); })?; @@ -111,6 +104,11 @@ fn terser_exec(input: PathBuf) { eprintln!("This test is not executable test"); })?; + if input_stdout != expected_stdout { + eprintln!("This test is not for execution"); + return Err(()); + } + eprintln!("Optimizing"); let output = run(cm.clone(), &handler, &input, &config); @@ -122,6 +120,14 @@ fn terser_exec(input: PathBuf) { let actual = print(cm, &[output_module], false, false); let actual_stdout = stdout_of(&actual, Duration::from_secs(5)).unwrap(); + eprintln!( + "---- {} -----\n{}", + Color::Green.paint("Expected"), + expected_src + ); + + eprintln!("---- {} -----\n{}", Color::Green.paint("Actual"), actual); + eprintln!( "---- {} -----\n{}", Color::Green.paint("Expected stdout"), @@ -169,6 +175,9 @@ fn run(cm: Lrc, handler: &Handler, input: &Path, config: &str) -> Opt .build_global(); let (_module, config) = parse_compressor_config(cm.clone(), config); + if config.ie8 { + return None; + } let fm = cm.load_file(input).expect("failed to load input.js"); let comments = SingleThreadedComments::default();