diff --git a/crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedEnums_es2015.2.minified.js b/crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedEnums_es2015.2.minified.js index 4528dfdf955..30638d1aeaa 100644 --- a/crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedEnums_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedEnums_es2015.2.minified.js @@ -1,8 +1,7 @@ var A; !function(A1) { var Color, Day; - let Color; - (Color = Color = A1.Color || (A1.Color = {}))[Color.Red = 0] = "Red", Color[Color.Blue = 1] = "Blue"; - let Day; - (Day = Day || (Day = {}))[Day.Monday = 0] = "Monday", Day[Day.Tuesday = 1] = "Tuesday"; + (Color = A1.Color || (A1.Color = {}))[Color.Red = 0] = "Red", Color[Color.Blue = 1] = "Blue"; + let Day1; + (Day = Day1 || (Day1 = {}))[Day.Monday = 0] = "Monday", Day[Day.Tuesday = 1] = "Tuesday"; }(A || (A = {})), A.Color.Red, A.Day.Monday; diff --git a/crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedEnums_es5.2.minified.js b/crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedEnums_es5.2.minified.js index ef51b75198d..30bc0fe1fe5 100644 --- a/crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedEnums_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedEnums_es5.2.minified.js @@ -1,5 +1,5 @@ var A; !function(A1) { - var Color, Day, Color, Day; - (Color = Color = A1.Color || (A1.Color = {}))[Color.Red = 0] = "Red", Color[Color.Blue = 1] = "Blue", (Day = Day || (Day = {}))[Day.Monday = 0] = "Monday", Day[Day.Tuesday = 1] = "Tuesday"; + var Day, Color, Day1; + (Color = A1.Color || (A1.Color = {}))[Color.Red = 0] = "Red", Color[Color.Blue = 1] = "Blue", (Day1 = Day || (Day = {}))[Day1.Monday = 0] = "Monday", Day1[Day1.Tuesday = 1] = "Tuesday"; }(A || (A = {})), A.Color.Red, A.Day.Monday; diff --git a/crates/swc/tests/tsc-references/callSignatureWithoutReturnTypeAnnotationInference_es2015.2.minified.js b/crates/swc/tests/tsc-references/callSignatureWithoutReturnTypeAnnotationInference_es2015.2.minified.js index 64acd9bb0af..df0653543ce 100644 --- a/crates/swc/tests/tsc-references/callSignatureWithoutReturnTypeAnnotationInference_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/callSignatureWithoutReturnTypeAnnotationInference_es2015.2.minified.js @@ -1,14 +1,11 @@ -var x1, M, e1; +var M, e1; function foo3() { return foo3(); } function m1() { return 1; } -x1 = 1, function(x) { - var x1; - x1 = 1; -}(1), foo3(), function(x) { +foo3(), function(x) { try {} catch (e) { return []; } finally{} diff --git a/crates/swc/tests/tsc-references/callSignatureWithoutReturnTypeAnnotationInference_es5.2.minified.js b/crates/swc/tests/tsc-references/callSignatureWithoutReturnTypeAnnotationInference_es5.2.minified.js index 54c2042587f..fabed6f4944 100644 --- a/crates/swc/tests/tsc-references/callSignatureWithoutReturnTypeAnnotationInference_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/callSignatureWithoutReturnTypeAnnotationInference_es5.2.minified.js @@ -2,17 +2,14 @@ import * as swcHelpers from "@swc/helpers"; function foo3() { return foo3(); } -x1 = 1, function(x) { - var x1; - x1 = 1; -}(1), foo3(), function(x) { +foo3(), function(x) { try {} catch (e) { return []; } finally{} }(1), function(x) { void 0 === x || swcHelpers.typeOf(x); }(1); -var x1, M, e1, C = function() { +var M, e1, C = function() { "use strict"; swcHelpers.classCallCheck(this, C); }; diff --git a/crates/swc/tests/tsc-references/constAssertionOnEnum_es2015.2.minified.js b/crates/swc/tests/tsc-references/constAssertionOnEnum_es2015.2.minified.js index a69dc72028f..ed13358bc96 100644 --- a/crates/swc/tests/tsc-references/constAssertionOnEnum_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/constAssertionOnEnum_es2015.2.minified.js @@ -6,8 +6,7 @@ export var Foo; Bar[Bar.A = 0] = "A", Bar[Bar.B = 1] = "B"; }(Bar || (Bar = {})), Foo.A, Bar.A, function(ns1) { var Foo; - let Foo; - (Foo = Foo = ns1.Foo || (ns1.Foo = {}))[Foo.X = 0] = "X", ns.Foo.X; + (Foo = ns1.Foo || (ns1.Foo = {}))[Foo.X = 0] = "X", ns.Foo.X; }(ns || (ns = {})), function(Foo) { Foo[Foo.X = 0] = "X"; }(Foo || (Foo = {})), Foo.X; diff --git a/crates/swc/tests/tsc-references/constAssertionOnEnum_es5.2.minified.js b/crates/swc/tests/tsc-references/constAssertionOnEnum_es5.2.minified.js index 1148b36baf0..ed13358bc96 100644 --- a/crates/swc/tests/tsc-references/constAssertionOnEnum_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/constAssertionOnEnum_es5.2.minified.js @@ -5,8 +5,8 @@ export var Foo; }(Foo || (Foo = {})), function(Bar) { Bar[Bar.A = 0] = "A", Bar[Bar.B = 1] = "B"; }(Bar || (Bar = {})), Foo.A, Bar.A, function(ns1) { - var Foo, Foo; - (Foo = Foo = ns1.Foo || (ns1.Foo = {}))[Foo.X = 0] = "X", ns.Foo.X; + var Foo; + (Foo = ns1.Foo || (ns1.Foo = {}))[Foo.X = 0] = "X", ns.Foo.X; }(ns || (ns = {})), function(Foo) { Foo[Foo.X = 0] = "X"; }(Foo || (Foo = {})), Foo.X; diff --git a/crates/swc/tests/tsc-references/enumMergingErrors_es2015.2.minified.js b/crates/swc/tests/tsc-references/enumMergingErrors_es2015.2.minified.js index c2cc328b861..b8638f06f70 100644 --- a/crates/swc/tests/tsc-references/enumMergingErrors_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/enumMergingErrors_es2015.2.minified.js @@ -1,50 +1,29 @@ var M, M1, M2; !function(M3) { var E1, E2, E3; - let E1; - (E1 = E1 = M3.E1 || (M3.E1 = {}))[E1.A = 0] = "A"; - let E2; - (E2 = E2 = M3.E2 || (M3.E2 = {}))[E2.C = 0] = "C"; - let E3; - (E3 = E3 = M3.E3 || (M3.E3 = {}))[E3.A = 0] = "A"; + (E1 = M3.E1 || (M3.E1 = {}))[E1.A = 0] = "A", (E2 = M3.E2 || (M3.E2 = {}))[E2.C = 0] = "C", (E3 = M3.E3 || (M3.E3 = {}))[E3.A = 0] = "A"; }(M || (M = {})), function(M4) { var E1, E2, E3; - let E1; - (E1 = E1 = M4.E1 || (M4.E1 = {}))[E1.B = 3] = "B"; - let E2; - (E2 = E2 = M4.E2 || (M4.E2 = {}))[E2.B = 3] = "B"; - let E3; - (E3 = E3 = M4.E3 || (M4.E3 = {}))[E3.C = 0] = "C"; + (E1 = M4.E1 || (M4.E1 = {}))[E1.B = 3] = "B", (E2 = M4.E2 || (M4.E2 = {}))[E2.B = 3] = "B", (E3 = M4.E3 || (M4.E3 = {}))[E3.C = 0] = "C"; }(M || (M = {})), function(M5) { var E1, E2, E3; - let E1; - (E1 = E1 = M5.E1 || (M5.E1 = {}))[E1.C = 0] = "C"; - let E2; - (E2 = E2 = M5.E2 || (M5.E2 = {}))[E2.A = 0] = "A"; - let E3; - (E3 = E3 = M5.E3 || (M5.E3 = {}))[E3.B = 3] = "B"; + (E1 = M5.E1 || (M5.E1 = {}))[E1.C = 0] = "C", (E2 = M5.E2 || (M5.E2 = {}))[E2.A = 0] = "A", (E3 = M5.E3 || (M5.E3 = {}))[E3.B = 3] = "B"; }(M || (M = {})), function(M11) { var E1; - let E1; - (E1 = E1 = M11.E1 || (M11.E1 = {}))[E1.A = 0] = "A"; + (E1 = M11.E1 || (M11.E1 = {}))[E1.A = 0] = "A"; }(M1 || (M1 = {})), function(M12) { var E1; - let E1; - (E1 = E1 = M12.E1 || (M12.E1 = {}))[E1.B = 0] = "B"; + (E1 = M12.E1 || (M12.E1 = {}))[E1.B = 0] = "B"; }(M1 || (M1 = {})), function(M13) { var E1; - let E1; - (E1 = E1 = M13.E1 || (M13.E1 = {}))[E1.C = 0] = "C"; + (E1 = M13.E1 || (M13.E1 = {}))[E1.C = 0] = "C"; }(M1 || (M1 = {})), function(M21) { var E1; - let E1; - (E1 = E1 = M21.E1 || (M21.E1 = {}))[E1.A = 0] = "A"; + (E1 = M21.E1 || (M21.E1 = {}))[E1.A = 0] = "A"; }(M2 || (M2 = {})), function(M22) { var E1; - let E1; - (E1 = E1 = M22.E1 || (M22.E1 = {}))[E1.B = 0] = "B"; + (E1 = M22.E1 || (M22.E1 = {}))[E1.B = 0] = "B"; }(M2 || (M2 = {})), function(M23) { var E1; - let E1; - (E1 = E1 = M23.E1 || (M23.E1 = {}))[E1.C = 0] = "C"; + (E1 = M23.E1 || (M23.E1 = {}))[E1.C = 0] = "C"; }(M2 || (M2 = {})); diff --git a/crates/swc/tests/tsc-references/enumMergingErrors_es5.2.minified.js b/crates/swc/tests/tsc-references/enumMergingErrors_es5.2.minified.js index cf214257f21..b8638f06f70 100644 --- a/crates/swc/tests/tsc-references/enumMergingErrors_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/enumMergingErrors_es5.2.minified.js @@ -1,29 +1,29 @@ var M, M1, M2; !function(M3) { - var E1, E2, E3, E1, E2, E3; - (E1 = E1 = M3.E1 || (M3.E1 = {}))[E1.A = 0] = "A", (E2 = E2 = M3.E2 || (M3.E2 = {}))[E2.C = 0] = "C", (E3 = E3 = M3.E3 || (M3.E3 = {}))[E3.A = 0] = "A"; + var E1, E2, E3; + (E1 = M3.E1 || (M3.E1 = {}))[E1.A = 0] = "A", (E2 = M3.E2 || (M3.E2 = {}))[E2.C = 0] = "C", (E3 = M3.E3 || (M3.E3 = {}))[E3.A = 0] = "A"; }(M || (M = {})), function(M4) { - var E1, E2, E3, E1, E2, E3; - (E1 = E1 = M4.E1 || (M4.E1 = {}))[E1.B = 3] = "B", (E2 = E2 = M4.E2 || (M4.E2 = {}))[E2.B = 3] = "B", (E3 = E3 = M4.E3 || (M4.E3 = {}))[E3.C = 0] = "C"; + var E1, E2, E3; + (E1 = M4.E1 || (M4.E1 = {}))[E1.B = 3] = "B", (E2 = M4.E2 || (M4.E2 = {}))[E2.B = 3] = "B", (E3 = M4.E3 || (M4.E3 = {}))[E3.C = 0] = "C"; }(M || (M = {})), function(M5) { - var E1, E2, E3, E1, E2, E3; - (E1 = E1 = M5.E1 || (M5.E1 = {}))[E1.C = 0] = "C", (E2 = E2 = M5.E2 || (M5.E2 = {}))[E2.A = 0] = "A", (E3 = E3 = M5.E3 || (M5.E3 = {}))[E3.B = 3] = "B"; + var E1, E2, E3; + (E1 = M5.E1 || (M5.E1 = {}))[E1.C = 0] = "C", (E2 = M5.E2 || (M5.E2 = {}))[E2.A = 0] = "A", (E3 = M5.E3 || (M5.E3 = {}))[E3.B = 3] = "B"; }(M || (M = {})), function(M11) { - var E1, E1; - (E1 = E1 = M11.E1 || (M11.E1 = {}))[E1.A = 0] = "A"; + var E1; + (E1 = M11.E1 || (M11.E1 = {}))[E1.A = 0] = "A"; }(M1 || (M1 = {})), function(M12) { - var E1, E1; - (E1 = E1 = M12.E1 || (M12.E1 = {}))[E1.B = 0] = "B"; + var E1; + (E1 = M12.E1 || (M12.E1 = {}))[E1.B = 0] = "B"; }(M1 || (M1 = {})), function(M13) { - var E1, E1; - (E1 = E1 = M13.E1 || (M13.E1 = {}))[E1.C = 0] = "C"; + var E1; + (E1 = M13.E1 || (M13.E1 = {}))[E1.C = 0] = "C"; }(M1 || (M1 = {})), function(M21) { - var E1, E1; - (E1 = E1 = M21.E1 || (M21.E1 = {}))[E1.A = 0] = "A"; + var E1; + (E1 = M21.E1 || (M21.E1 = {}))[E1.A = 0] = "A"; }(M2 || (M2 = {})), function(M22) { - var E1, E1; - (E1 = E1 = M22.E1 || (M22.E1 = {}))[E1.B = 0] = "B"; + var E1; + (E1 = M22.E1 || (M22.E1 = {}))[E1.B = 0] = "B"; }(M2 || (M2 = {})), function(M23) { - var E1, E1; - (E1 = E1 = M23.E1 || (M23.E1 = {}))[E1.C = 0] = "C"; + var E1; + (E1 = M23.E1 || (M23.E1 = {}))[E1.C = 0] = "C"; }(M2 || (M2 = {})); diff --git a/crates/swc/tests/tsc-references/enumMerging_es2015.2.minified.js b/crates/swc/tests/tsc-references/enumMerging_es2015.2.minified.js index e197bbfd330..db8c27a4c08 100644 --- a/crates/swc/tests/tsc-references/enumMerging_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/enumMerging_es2015.2.minified.js @@ -1,32 +1,29 @@ var M1, M2, M3, M4, M5, M6; !function(M11) { - var EImpl1, EImpl1, EConst1, EConst1; - let EImpl1; - (EImpl1 = EImpl1 || (EImpl1 = {}))[EImpl1.A = 0] = "A", EImpl1[EImpl1.B = 1] = "B", EImpl1[EImpl1.C = 2] = "C", (EImpl1 = EImpl1 || (EImpl1 = {}))[EImpl1.D = 1] = "D", EImpl1[EImpl1.E = 2] = "E", EImpl1[EImpl1.F = 3] = "F"; - let EConst1; - (EConst1 = EConst1 = M11.EConst1 || (M11.EConst1 = {}))[EConst1.A = 3] = "A", EConst1[EConst1.B = 2] = "B", EConst1[EConst1.C = 1] = "C", (EConst1 = EConst1 = M11.EConst1 || (M11.EConst1 = {}))[EConst1.D = 7] = "D", EConst1[EConst1.E = 9] = "E", EConst1[EConst1.F = 8] = "F", EConst1.A, EConst1.B, EConst1.C, EConst1.D, EConst1.E, EConst1.F; + var EImpl1, EImpl11, EConst1, EConst11; + let EImpl12; + (EImpl1 = EImpl12 || (EImpl12 = {}))[EImpl1.A = 0] = "A", EImpl1[EImpl1.B = 1] = "B", EImpl1[EImpl1.C = 2] = "C", (EImpl11 = EImpl12 || (EImpl12 = {}))[EImpl11.D = 1] = "D", EImpl11[EImpl11.E = 2] = "E", EImpl11[EImpl11.F = 3] = "F"; + let EConst12; + (EConst1 = EConst12 = M11.EConst1 || (M11.EConst1 = {}))[EConst1.A = 3] = "A", EConst1[EConst1.B = 2] = "B", EConst1[EConst1.C = 1] = "C", (EConst11 = EConst12 = M11.EConst1 || (M11.EConst1 = {}))[EConst11.D = 7] = "D", EConst11[EConst11.E = 9] = "E", EConst11[EConst11.F = 8] = "F", EConst12.A, EConst12.B, EConst12.C, EConst12.D, EConst12.E, EConst12.F; }(M1 || (M1 = {})), function(M21) { - var EComp2, EComp2; - let EComp2; - (EComp2 = EComp2 = M21.EComp2 || (M21.EComp2 = {}))[EComp2.A = 3] = "A", EComp2[EComp2.B = 3] = "B", EComp2[EComp2.C = 3] = "C", (EComp2 = EComp2 = M21.EComp2 || (M21.EComp2 = {}))[EComp2.D = 3] = "D", EComp2[EComp2.E = 3] = "E", EComp2[EComp2.F = 3] = "F", EComp2.A, EComp2.B, EComp2.C, EComp2.D, EComp2.E, EComp2.F; + var EComp2, EComp21; + let EComp22; + (EComp2 = EComp22 = M21.EComp2 || (M21.EComp2 = {}))[EComp2.A = 3] = "A", EComp2[EComp2.B = 3] = "B", EComp2[EComp2.C = 3] = "C", (EComp21 = EComp22 = M21.EComp2 || (M21.EComp2 = {}))[EComp21.D = 3] = "D", EComp21[EComp21.E = 3] = "E", EComp21[EComp21.F = 3] = "F", EComp22.A, EComp22.B, EComp22.C, EComp22.D, EComp22.E, EComp22.F; }(M2 || (M2 = {})), function(M3) { - var EInit, EInit; - let EInit; - (EInit = EInit || (EInit = {}))[EInit.A = 0] = "A", EInit[EInit.B = 1] = "B", (EInit = EInit || (EInit = {}))[EInit.C = 1] = "C", EInit[EInit.D = 2] = "D", EInit[EInit.E = 3] = "E"; + var EInit, EInit1; + let EInit2; + (EInit = EInit2 || (EInit2 = {}))[EInit.A = 0] = "A", EInit[EInit.B = 1] = "B", (EInit1 = EInit2 || (EInit2 = {}))[EInit1.C = 1] = "C", EInit1[EInit1.D = 2] = "D", EInit1[EInit1.E = 3] = "E"; }(M3 || (M3 = {})), function(M41) { var Color; - let Color; - (Color = Color = M41.Color || (M41.Color = {}))[Color.Red = 0] = "Red", Color[Color.Green = 1] = "Green", Color[Color.Blue = 2] = "Blue"; + (Color = M41.Color || (M41.Color = {}))[Color.Red = 0] = "Red", Color[Color.Green = 1] = "Green", Color[Color.Blue = 2] = "Blue"; }(M4 || (M4 = {})), function(M51) { var Color; - let Color; - (Color = Color = M51.Color || (M51.Color = {}))[Color.Red = 0] = "Red", Color[Color.Green = 1] = "Green", Color[Color.Blue = 2] = "Blue"; + (Color = M51.Color || (M51.Color = {}))[Color.Red = 0] = "Red", Color[Color.Green = 1] = "Green", Color[Color.Blue = 2] = "Blue"; }(M5 || (M5 = {})), function(M61) { var A, Color; - let Color; - (Color = Color = (A = M61.A || (M61.A = {})).Color || (A.Color = {}))[Color.Red = 0] = "Red", Color[Color.Green = 1] = "Green", Color[Color.Blue = 2] = "Blue"; + (Color = (A = M61.A || (M61.A = {})).Color || (A.Color = {}))[Color.Red = 0] = "Red", Color[Color.Green = 1] = "Green", Color[Color.Blue = 2] = "Blue"; }(M6 || (M6 = {})), function(M62) { var A, Color; - let A1, Color; - (Color = Color = (A = A1 = M62.A || (M62.A = {})).Color || (A.Color = {}))[Color.Yellow = 1] = "Yellow", A1.Color.Yellow, A1.Color.Red; + let A1; + (Color = (A = A1 = M62.A || (M62.A = {})).Color || (A.Color = {}))[Color.Yellow = 1] = "Yellow", A1.Color.Yellow, A1.Color.Red; }(M6 || (M6 = {})); diff --git a/crates/swc/tests/tsc-references/enumMerging_es5.2.minified.js b/crates/swc/tests/tsc-references/enumMerging_es5.2.minified.js index 0dd7fa54a3e..11ccce58dfe 100644 --- a/crates/swc/tests/tsc-references/enumMerging_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/enumMerging_es5.2.minified.js @@ -1,23 +1,23 @@ var M1, M2, M3, M4, M5, M6; !function(M11) { - var EImpl1, EImpl1, EConst1, EConst1, EImpl1, EConst1; - (EImpl1 = EImpl1 || (EImpl1 = {}))[EImpl1.A = 0] = "A", EImpl1[EImpl1.B = 1] = "B", EImpl1[EImpl1.C = 2] = "C", (EImpl1 = EImpl1 || (EImpl1 = {}))[EImpl1.D = 1] = "D", EImpl1[EImpl1.E = 2] = "E", EImpl1[EImpl1.F = 3] = "F", (EConst1 = EConst1 = M11.EConst1 || (M11.EConst1 = {}))[EConst1.A = 3] = "A", EConst1[EConst1.B = 2] = "B", EConst1[EConst1.C = 1] = "C", (EConst1 = EConst1 = M11.EConst1 || (M11.EConst1 = {}))[EConst1.D = 7] = "D", EConst1[EConst1.E = 9] = "E", EConst1[EConst1.F = 8] = "F", EConst1.A, EConst1.B, EConst1.C, EConst1.D, EConst1.E, EConst1.F; + var EImpl1, EImpl11, EConst1, EConst11, EImpl12, EConst12; + (EImpl1 = EImpl12 || (EImpl12 = {}))[EImpl1.A = 0] = "A", EImpl1[EImpl1.B = 1] = "B", EImpl1[EImpl1.C = 2] = "C", (EImpl11 = EImpl12 || (EImpl12 = {}))[EImpl11.D = 1] = "D", EImpl11[EImpl11.E = 2] = "E", EImpl11[EImpl11.F = 3] = "F", (EConst1 = EConst12 = M11.EConst1 || (M11.EConst1 = {}))[EConst1.A = 3] = "A", EConst1[EConst1.B = 2] = "B", EConst1[EConst1.C = 1] = "C", (EConst11 = EConst12 = M11.EConst1 || (M11.EConst1 = {}))[EConst11.D = 7] = "D", EConst11[EConst11.E = 9] = "E", EConst11[EConst11.F = 8] = "F", EConst12.A, EConst12.B, EConst12.C, EConst12.D, EConst12.E, EConst12.F; }(M1 || (M1 = {})), function(M21) { - var EComp2, EComp2, EComp2; - (EComp2 = EComp2 = M21.EComp2 || (M21.EComp2 = {}))[EComp2.A = 3] = "A", EComp2[EComp2.B = 3] = "B", EComp2[EComp2.C = 3] = "C", (EComp2 = EComp2 = M21.EComp2 || (M21.EComp2 = {}))[EComp2.D = 3] = "D", EComp2[EComp2.E = 3] = "E", EComp2[EComp2.F = 3] = "F", EComp2.A, EComp2.B, EComp2.C, EComp2.D, EComp2.E, EComp2.F; + var EComp2, EComp21, EComp22; + (EComp2 = EComp22 = M21.EComp2 || (M21.EComp2 = {}))[EComp2.A = 3] = "A", EComp2[EComp2.B = 3] = "B", EComp2[EComp2.C = 3] = "C", (EComp21 = EComp22 = M21.EComp2 || (M21.EComp2 = {}))[EComp21.D = 3] = "D", EComp21[EComp21.E = 3] = "E", EComp21[EComp21.F = 3] = "F", EComp22.A, EComp22.B, EComp22.C, EComp22.D, EComp22.E, EComp22.F; }(M2 || (M2 = {})), function(M3) { - var EInit, EInit, EInit; - (EInit = EInit || (EInit = {}))[EInit.A = 0] = "A", EInit[EInit.B = 1] = "B", (EInit = EInit || (EInit = {}))[EInit.C = 1] = "C", EInit[EInit.D = 2] = "D", EInit[EInit.E = 3] = "E"; + var EInit, EInit1, EInit2; + (EInit1 = EInit || (EInit = {}))[EInit1.A = 0] = "A", EInit1[EInit1.B = 1] = "B", (EInit2 = EInit || (EInit = {}))[EInit2.C = 1] = "C", EInit2[EInit2.D = 2] = "D", EInit2[EInit2.E = 3] = "E"; }(M3 || (M3 = {})), function(M41) { - var Color, Color; - (Color = Color = M41.Color || (M41.Color = {}))[Color.Red = 0] = "Red", Color[Color.Green = 1] = "Green", Color[Color.Blue = 2] = "Blue"; + var Color; + (Color = M41.Color || (M41.Color = {}))[Color.Red = 0] = "Red", Color[Color.Green = 1] = "Green", Color[Color.Blue = 2] = "Blue"; }(M4 || (M4 = {})), function(M51) { - var Color, Color; - (Color = Color = M51.Color || (M51.Color = {}))[Color.Red = 0] = "Red", Color[Color.Green = 1] = "Green", Color[Color.Blue = 2] = "Blue"; + var Color; + (Color = M51.Color || (M51.Color = {}))[Color.Red = 0] = "Red", Color[Color.Green = 1] = "Green", Color[Color.Blue = 2] = "Blue"; }(M5 || (M5 = {})), function(M61) { - var A, Color, Color; - (Color = Color = (A = M61.A || (M61.A = {})).Color || (A.Color = {}))[Color.Red = 0] = "Red", Color[Color.Green = 1] = "Green", Color[Color.Blue = 2] = "Blue"; + var A, Color; + (Color = (A = M61.A || (M61.A = {})).Color || (A.Color = {}))[Color.Red = 0] = "Red", Color[Color.Green = 1] = "Green", Color[Color.Blue = 2] = "Blue"; }(M6 || (M6 = {})), function(M62) { - var A, Color, Color, A1; - (Color = Color = (A = A1 = M62.A || (M62.A = {})).Color || (A.Color = {}))[Color.Yellow = 1] = "Yellow", A1.Color.Yellow, A1.Color.Red; + var A, Color, A1; + (Color = (A = A1 = M62.A || (M62.A = {})).Color || (A.Color = {}))[Color.Yellow = 1] = "Yellow", A1.Color.Yellow, A1.Color.Red; }(M6 || (M6 = {})); 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 d3eec5f609f..5d284d5e42a 100644 --- a/crates/swc/tests/tsc-references/exportCodeGen_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/exportCodeGen_es2015.2.minified.js @@ -3,11 +3,10 @@ var A, D, E, F; return !0; }, function(E1) { var Color; - let Color; - (Color = Color = E1.Color || (E1.Color = {}))[Color.Red = 0] = "Red", E1.fn = function() {}, E1.C = class { + (Color = E1.Color || (E1.Color = {}))[Color.Red = 0] = "Red", E1.fn = function() {}, E1.C = class { }, (E1.M || (E1.M = {})).x = 42; }(E || (E = {})), function(F) { var Color; - let Color; - (Color = Color || (Color = {}))[Color.Red = 0] = "Red"; + let Color1; + (Color = Color1 || (Color1 = {}))[Color.Red = 0] = "Red"; }(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 e86c2cb8006..264377d9a89 100644 --- a/crates/swc/tests/tsc-references/exportCodeGen_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/exportCodeGen_es5.2.minified.js @@ -3,15 +3,15 @@ import * as swcHelpers from "@swc/helpers"; (A || (A = {})).x = 12, (D || (D = {})).yes = function() { return !0; }, function(E1) { - (Color = Color = E1.Color || (E1.Color = {}))[Color.Red = 0] = "Red", E1.fn = function() {}; - var Color, Color, C = function() { + (Color = E1.Color || (E1.Color = {}))[Color.Red = 0] = "Red", E1.fn = function() {}; + var Color, C = function() { "use strict"; swcHelpers.classCallCheck(this, C); }; E1.C = C, (E1.M || (E1.M = {})).x = 42; }(E || (E = {})), function(F) { - (Color = Color || (Color = {}))[Color.Red = 0] = "Red"; - var Color, Color, C = function() { + (Color1 = Color || (Color = {}))[Color1.Red = 0] = "Red"; + var Color, Color1, C = function() { "use strict"; swcHelpers.classCallCheck(this, C); }; diff --git a/crates/swc/tests/tsc-references/genericCallWithGenericSignatureArguments2_es2015.2.minified.js b/crates/swc/tests/tsc-references/genericCallWithGenericSignatureArguments2_es2015.2.minified.js index 16c891c0d17..d3cdad02bff 100644 --- a/crates/swc/tests/tsc-references/genericCallWithGenericSignatureArguments2_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/genericCallWithGenericSignatureArguments2_es2015.2.minified.js @@ -1,18 +1,18 @@ var onlyT, TU; !function(onlyT) { var E, F; - let E; - (E = E || (E = {}))[E.A = 0] = "A"; - let F; - (F = F || (F = {}))[F.A = 0] = "A", function(x, a, b) {}(E.A, (x)=>E.A - , (x)=>F.A + let E1; + (E = E1 || (E1 = {}))[E.A = 0] = "A"; + let F1; + (F = F1 || (F1 = {}))[F.A = 0] = "A", function(x, a, b) {}(E1.A, (x)=>E1.A + , (x)=>F1.A ); }(onlyT || (onlyT = {})), function(TU) { var E, F; - let E; - (E = E || (E = {}))[E.A = 0] = "A"; - let F; - (F = F || (F = {}))[F.A = 0] = "A", function(x, a, b) {}(E.A, (x)=>E.A - , (x)=>F.A + let E2; + (E = E2 || (E2 = {}))[E.A = 0] = "A"; + let F2; + (F = F2 || (F2 = {}))[F.A = 0] = "A", function(x, a, b) {}(E2.A, (x)=>E2.A + , (x)=>F2.A ); }(TU || (TU = {})); diff --git a/crates/swc/tests/tsc-references/genericCallWithGenericSignatureArguments2_es5.2.minified.js b/crates/swc/tests/tsc-references/genericCallWithGenericSignatureArguments2_es5.2.minified.js index 2b3d05dc47c..2b7189c00d8 100644 --- a/crates/swc/tests/tsc-references/genericCallWithGenericSignatureArguments2_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/genericCallWithGenericSignatureArguments2_es5.2.minified.js @@ -1,22 +1,22 @@ var onlyT, TU; !function(onlyT) { - var E, F, E, F; + var E, F, E1, F1; (function(a, b) {})(function(x) { return 1; }, function(x) { return ""; - }), (E = E || (E = {}))[E.A = 0] = "A", (F = F || (F = {}))[F.A = 0] = "A", function(x, a, b) {}(E.A, function(x) { + }), (E1 = E || (E = {}))[E1.A = 0] = "A", (F1 = F || (F = {}))[F1.A = 0] = "A", function(x, a, b) {}(E.A, function(x) { return E.A; }, function(x) { return F.A; }); }(onlyT || (onlyT = {})), function(TU) { - var E, F, E, F; + var E, F, E2, F2; (function(a, b) {})(function(x) { return 1; }, function(x) { return ""; - }), (E = E || (E = {}))[E.A = 0] = "A", (F = F || (F = {}))[F.A = 0] = "A", function(x, a, b) {}(E.A, function(x) { + }), (E2 = E || (E = {}))[E2.A = 0] = "A", (F2 = F || (F = {}))[F2.A = 0] = "A", function(x, a, b) {}(E.A, function(x) { return E.A; }, function(x) { return F.A; diff --git a/crates/swc/tests/tsc-references/instantiatedModule_es2015.2.minified.js b/crates/swc/tests/tsc-references/instantiatedModule_es2015.2.minified.js index 2f559d6800e..f6ea28fa71b 100644 --- a/crates/swc/tests/tsc-references/instantiatedModule_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/instantiatedModule_es2015.2.minified.js @@ -11,8 +11,7 @@ M.Point, m.Point, (M2 || (M2 = {})).Point = class { var m2 = M2, a2 = m2.Point, a2 = M2.Point; a2.Origin(), new m2.Point(), new M2.Point(), function(M31) { var Color; - let Color; - (Color = Color = M31.Color || (M31.Color = {}))[Color.Blue = 0] = "Blue", Color[Color.Red = 1] = "Red"; + (Color = M31.Color || (M31.Color = {}))[Color.Blue = 0] = "Blue", Color[Color.Red = 1] = "Red"; }(M3 || (M3 = {})); var m3 = M3, a3 = m3.Color, a3 = M3.Color; a3.Blue, M3.Color.Red, m3.Color.Blue; diff --git a/crates/swc/tests/tsc-references/instantiatedModule_es5.2.minified.js b/crates/swc/tests/tsc-references/instantiatedModule_es5.2.minified.js index ddaffc14677..f1901cafc01 100644 --- a/crates/swc/tests/tsc-references/instantiatedModule_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/instantiatedModule_es5.2.minified.js @@ -18,8 +18,8 @@ M.Point, m.Point, function(M21) { }(M2 || (M2 = {})); var m2 = M2, a2 = m2.Point, a2 = M2.Point; a2.Origin(), new m2.Point(), new M2.Point(), function(M31) { - var Color, Color; - (Color = Color = M31.Color || (M31.Color = {}))[Color.Blue = 0] = "Blue", Color[Color.Red = 1] = "Red"; + var Color; + (Color = M31.Color || (M31.Color = {}))[Color.Blue = 0] = "Blue", Color[Color.Red = 1] = "Red"; }(M3 || (M3 = {})); var m3 = M3, a3 = m3.Color, a3 = M3.Color; a3.Blue, M3.Color.Red, m3.Color.Blue; diff --git a/crates/swc/tests/tsc-references/localTypes1_es5.2.minified.js b/crates/swc/tests/tsc-references/localTypes1_es5.2.minified.js index 54ea51c7dc0..2cf6f98b822 100644 --- a/crates/swc/tests/tsc-references/localTypes1_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/localTypes1_es5.2.minified.js @@ -2,14 +2,14 @@ import * as swcHelpers from "@swc/helpers"; var A = function() { "use strict"; function A() { - swcHelpers.classCallCheck(this, A), (E = E || (E = {}))[E.A = 0] = "A", E[E.B = 1] = "B", E[E.C = 2] = "C"; - var E, E, C = function() { + swcHelpers.classCallCheck(this, A), (E = E1 || (E1 = {}))[E.A = 0] = "A", E[E.B = 1] = "B", E[E.C = 2] = "C"; + var E, E1, C = function() { swcHelpers.classCallCheck(this, C); }; } return A.prototype.m = function() { - (E = E || (E = {}))[E.A = 0] = "A", E[E.B = 1] = "B", E[E.C = 2] = "C"; - var E, E, C = function() { + (E = E2 || (E2 = {}))[E.A = 0] = "A", E[E.B = 1] = "B", E[E.C = 2] = "C"; + var E, E2, C = function() { swcHelpers.classCallCheck(this, C); }; return new C(); @@ -17,8 +17,8 @@ var A = function() { { key: "p", get: function() { - (E = E || (E = {}))[E.A = 0] = "A", E[E.B = 1] = "B", E[E.C = 2] = "C"; - var E, E, C = function() { + (E = E3 || (E3 = {}))[E.A = 0] = "A", E[E.B = 1] = "B", E[E.C = 2] = "C"; + var E, E3, C = function() { swcHelpers.classCallCheck(this, C); }; return new C(); 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 82636d6b57f..632610700e7 100644 --- a/crates/swc/tests/tsc-references/moduleWithStatementsOfEveryKind_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/moduleWithStatementsOfEveryKind_es2015.2.minified.js @@ -1,8 +1,8 @@ var A, Y; !function(A) { var Color; - let Color; - (Color = Color || (Color = {}))[Color.Blue = 0] = "Blue", Color[Color.Red = 1] = "Red"; + let Color1; + (Color = Color1 || (Color1 = {}))[Color.Blue = 0] = "Blue", Color[Color.Red = 1] = "Red"; }(A || (A = {})), function(Y1) { var Color; class A1 { @@ -12,9 +12,7 @@ var A, Y; } Y1.AA = AA, Y1.B = class extends AA { }, Y1.BB = class extends A1 { - }; - let Color; - (Color = Color = Y1.Color || (Y1.Color = {}))[Color.Blue = 0] = "Blue", Color[Color.Red = 1] = "Red", Y1.x = 12, Y1.F = function(s) { + }, (Color = Y1.Color || (Y1.Color = {}))[Color.Blue = 0] = "Blue", Color[Color.Red = 1] = "Red", Y1.x = 12, Y1.F = function(s) { return 2; }, Y1.array = null, Y1.fn = (s)=>'hello ' + s , Y1.ol = { diff --git a/crates/swc/tests/tsc-references/moduleWithStatementsOfEveryKind_es5.2.minified.js b/crates/swc/tests/tsc-references/moduleWithStatementsOfEveryKind_es5.2.minified.js index 81ae02c7934..218d544385f 100644 --- a/crates/swc/tests/tsc-references/moduleWithStatementsOfEveryKind_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/moduleWithStatementsOfEveryKind_es5.2.minified.js @@ -1,7 +1,7 @@ var A, Y; import * as swcHelpers from "@swc/helpers"; !function(A3) { - var Module, Color, A1, Color, A2 = function() { + var Module, Color, A1, Color1, A2 = function() { "use strict"; swcHelpers.classCallCheck(this, A2); }, AA1 = function() { @@ -27,9 +27,9 @@ import * as swcHelpers from "@swc/helpers"; Module || (Module = {}), A1 = function() { "use strict"; swcHelpers.classCallCheck(this, A1); - }, (Color = Color || (Color = {}))[Color.Blue = 0] = "Blue", Color[Color.Red = 1] = "Red"; + }, (Color1 = Color || (Color = {}))[Color1.Blue = 0] = "Blue", Color1[Color1.Red = 1] = "Red"; }(A || (A = {})), function(Y1) { - var Color, A6 = function() { + var A6 = function() { "use strict"; swcHelpers.classCallCheck(this, A6); }; @@ -61,7 +61,7 @@ import * as swcHelpers from "@swc/helpers"; Y1.BB = BB, Y1.Module || (Y1.Module = {}), A5 = function() { "use strict"; swcHelpers.classCallCheck(this, A5); - }, (Color = Color = Y1.Color || (Y1.Color = {}))[Color.Blue = 0] = "Blue", Color[Color.Red = 1] = "Red", Y1.x = 12, Y1.F = function(s) { + }, (Color = Y1.Color || (Y1.Color = {}))[Color.Blue = 0] = "Blue", Color[Color.Red = 1] = "Red", Y1.x = 12, Y1.F = function(s) { return 2; }, Y1.array = null, Y1.fn = function(s) { return "hello " + s; 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 a00c1713caf..e67e53fff85 100644 --- a/crates/swc/tests/tsc-references/nameCollision_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/nameCollision_es2015.2.minified.js @@ -3,6 +3,5 @@ var X, Y, D; X1.Y || (X1.Y = {}); }(X || (X = {})), function(Y3) { var Y1, Y2; - let Y2, Y2; - (Y2 = Y2 = (Y1 = Y2 = Y3.Y || (Y3.Y = {})).Y || (Y1.Y = {}))[Y2.Red = 0] = "Red", Y2[Y2.Blue = 1] = "Blue"; + (Y2 = (Y1 = Y3.Y || (Y3.Y = {})).Y || (Y1.Y = {}))[Y2.Red = 0] = "Red", Y2[Y2.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 10b7318aa29..a16f6efc86f 100644 --- a/crates/swc/tests/tsc-references/nameCollision_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/nameCollision_es5.2.minified.js @@ -8,6 +8,6 @@ import * as swcHelpers from "@swc/helpers"; }(B || (B = {})), function(X1) { X1.Y || (X1.Y = {}); }(X || (X = {})), function(Y2) { - var _$Y, Y1, _$Y, _$Y; - (_$Y = _$Y = (Y1 = _$Y = Y2.Y || (Y2.Y = {})).Y || (Y1.Y = {}))[_$Y.Red = 0] = "Red", _$Y[_$Y.Blue = 1] = "Blue"; + var Y1, _$Y; + (_$Y = (Y1 = Y2.Y || (Y2.Y = {})).Y || (Y1.Y = {}))[_$Y.Red = 0] = "Red", _$Y[_$Y.Blue = 1] = "Blue"; }(Y || (Y = {})), (D || (D = {})).E = "hello"; diff --git a/crates/swc/tests/tsc-references/parserRealSource14_es2015.2.minified.js b/crates/swc/tests/tsc-references/parserRealSource14_es2015.2.minified.js index 764827314b5..3225bdb54ae 100644 --- a/crates/swc/tests/tsc-references/parserRealSource14_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/parserRealSource14_es2015.2.minified.js @@ -217,8 +217,8 @@ var TypeScript; } } TypeScript1.AstPathContext = AstPathContext; - let GetAstPathOptions; - (GetAstPathOptions = GetAstPathOptions = TypeScript1.GetAstPathOptions || (TypeScript1.GetAstPathOptions = {}))[GetAstPathOptions.Default = 0] = "Default", GetAstPathOptions[GetAstPathOptions.EdgeInclusive = 1] = "EdgeInclusive", GetAstPathOptions[GetAstPathOptions.DontPruneSearchBasedOnPosition = 2] = "DontPruneSearchBasedOnPosition", TypeScript1.getAstPathToPosition = function(script, pos, options = GetAstPathOptions.Default) { + let GetAstPathOptions1; + (GetAstPathOptions = GetAstPathOptions1 = TypeScript1.GetAstPathOptions || (TypeScript1.GetAstPathOptions = {}))[GetAstPathOptions.Default = 0] = "Default", GetAstPathOptions[GetAstPathOptions.EdgeInclusive = 1] = "EdgeInclusive", GetAstPathOptions[GetAstPathOptions.DontPruneSearchBasedOnPosition = 2] = "DontPruneSearchBasedOnPosition", TypeScript1.getAstPathToPosition = function(script, pos, options = GetAstPathOptions1.Default) { var lookInComments = (comments)=>{ if (comments && comments.length > 0) for(var i = 0; i < comments.length; i++){ var minChar = comments[i].minChar, limChar = comments[i].limChar; @@ -226,12 +226,12 @@ var TypeScript; } }, pre = function(cur, parent, walker) { if (isValidAstNode(cur)) { - var inclusive = hasFlag(options, GetAstPathOptions.EdgeInclusive) || cur.nodeType === TypeScript.NodeType.Name || pos === script.limChar, minChar = cur.minChar, limChar = cur.limChar + (inclusive ? 1 : 0); + var inclusive = hasFlag(options, GetAstPathOptions1.EdgeInclusive) || cur.nodeType === TypeScript.NodeType.Name || pos === script.limChar, minChar = cur.minChar, limChar = cur.limChar + (inclusive ? 1 : 0); if (pos >= minChar && pos < limChar) { var previous = ctx.path.ast(); (null == previous || cur.minChar >= previous.minChar && cur.limChar <= previous.limChar) && ctx.path.push(cur); } - pos < limChar && lookInComments(cur.preComments), pos >= minChar && lookInComments(cur.postComments), hasFlag(options, GetAstPathOptions.DontPruneSearchBasedOnPosition) || (walker.options.goChildren = minChar <= pos && pos <= limChar); + pos < limChar && lookInComments(cur.preComments), pos >= minChar && lookInComments(cur.postComments), hasFlag(options, GetAstPathOptions1.DontPruneSearchBasedOnPosition) || (walker.options.goChildren = minChar <= pos && pos <= limChar); } return cur; }, ctx = new AstPathContext(); diff --git a/crates/swc/tests/tsc-references/parserRealSource14_es5.2.minified.js b/crates/swc/tests/tsc-references/parserRealSource14_es5.2.minified.js index d7a1952c1e9..1b80a0a36f6 100644 --- a/crates/swc/tests/tsc-references/parserRealSource14_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/parserRealSource14_es5.2.minified.js @@ -184,9 +184,9 @@ import * as swcHelpers from "@swc/helpers"; }, AstPath; }(); TypeScript1.AstPath = AstPath, TypeScript1.isValidAstNode = isValidAstNode; - var GetAstPathOptions, AstPathContext = function AstPathContext() { + var GetAstPathOptions1, AstPathContext = function AstPathContext() { "use strict"; swcHelpers.classCallCheck(this, AstPathContext), this.path = new TypeScript.AstPath(); }; - TypeScript1.AstPathContext = AstPathContext, (GetAstPathOptions = GetAstPathOptions = TypeScript1.GetAstPathOptions || (TypeScript1.GetAstPathOptions = {}))[GetAstPathOptions.Default = 0] = "Default", GetAstPathOptions[GetAstPathOptions.EdgeInclusive = 1] = "EdgeInclusive", GetAstPathOptions[GetAstPathOptions.DontPruneSearchBasedOnPosition = 2] = "DontPruneSearchBasedOnPosition", TypeScript1.getAstPathToPosition = getAstPathToPosition, TypeScript1.getTokenizationOffset = getTokenizationOffset, TypeScript1.walkAST = walkAST; + TypeScript1.AstPathContext = AstPathContext, (GetAstPathOptions1 = GetAstPathOptions = TypeScript1.GetAstPathOptions || (TypeScript1.GetAstPathOptions = {}))[GetAstPathOptions1.Default = 0] = "Default", GetAstPathOptions1[GetAstPathOptions1.EdgeInclusive = 1] = "EdgeInclusive", GetAstPathOptions1[GetAstPathOptions1.DontPruneSearchBasedOnPosition = 2] = "DontPruneSearchBasedOnPosition", TypeScript1.getAstPathToPosition = getAstPathToPosition, TypeScript1.getTokenizationOffset = getTokenizationOffset, TypeScript1.walkAST = walkAST; }(TypeScript || (TypeScript = {})); diff --git a/crates/swc/tests/tsc-references/parserRealSource2_es2015.2.minified.js b/crates/swc/tests/tsc-references/parserRealSource2_es2015.2.minified.js index 482dfdbeca7..698a35d7187 100644 --- a/crates/swc/tests/tsc-references/parserRealSource2_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/parserRealSource2_es2015.2.minified.js @@ -3,37 +3,13 @@ var TypeScript; var ErrorRecoverySet, AllowedElements, Modifiers, ASTFlags, DeclFlags, ModuleFlags, SymbolFlags, VarFlags, FncFlags, SignatureFlags, TypeFlags, TypeRelationshipFlags, CodeGenTarget, ModuleGenTarget; TypeScript1.hasFlag = function(val, flag) { return (val & flag) != 0; - }; - let ErrorRecoverySet; - (ErrorRecoverySet = ErrorRecoverySet = TypeScript1.ErrorRecoverySet || (TypeScript1.ErrorRecoverySet = {}))[ErrorRecoverySet.None = 0] = "None", ErrorRecoverySet[ErrorRecoverySet.Comma = 1] = "Comma", ErrorRecoverySet[ErrorRecoverySet.SColon = 2] = "SColon", ErrorRecoverySet[ErrorRecoverySet.Asg = 4] = "Asg", ErrorRecoverySet[ErrorRecoverySet.BinOp = 8] = "BinOp", ErrorRecoverySet[ErrorRecoverySet.RBrack = 16] = "RBrack", ErrorRecoverySet[ErrorRecoverySet.RCurly = 32] = "RCurly", ErrorRecoverySet[ErrorRecoverySet.RParen = 64] = "RParen", ErrorRecoverySet[ErrorRecoverySet.Dot = 128] = "Dot", ErrorRecoverySet[ErrorRecoverySet.Colon = 256] = "Colon", ErrorRecoverySet[ErrorRecoverySet.PrimType = 512] = "PrimType", ErrorRecoverySet[ErrorRecoverySet.AddOp = 1024] = "AddOp", ErrorRecoverySet[ErrorRecoverySet.LCurly = 2048] = "LCurly", ErrorRecoverySet[ErrorRecoverySet.PreOp = 4096] = "PreOp", ErrorRecoverySet[ErrorRecoverySet.RegExp = 8192] = "RegExp", ErrorRecoverySet[ErrorRecoverySet.LParen = 16384] = "LParen", ErrorRecoverySet[ErrorRecoverySet.LBrack = 32768] = "LBrack", ErrorRecoverySet[ErrorRecoverySet.Scope = 65536] = "Scope", ErrorRecoverySet[ErrorRecoverySet.In = 131072] = "In", ErrorRecoverySet[ErrorRecoverySet.SCase = 262144] = "SCase", ErrorRecoverySet[ErrorRecoverySet.Else = 524288] = "Else", ErrorRecoverySet[ErrorRecoverySet.Catch = 1048576] = "Catch", ErrorRecoverySet[ErrorRecoverySet.Var = 2097152] = "Var", ErrorRecoverySet[ErrorRecoverySet.Stmt = 4194304] = "Stmt", ErrorRecoverySet[ErrorRecoverySet.While = 8388608] = "While", ErrorRecoverySet[ErrorRecoverySet.ID = 16777216] = "ID", ErrorRecoverySet[ErrorRecoverySet.Prefix = 33554432] = "Prefix", ErrorRecoverySet[ErrorRecoverySet.Literal = 67108864] = "Literal", ErrorRecoverySet[ErrorRecoverySet.RLit = 134217728] = "RLit", ErrorRecoverySet[ErrorRecoverySet.Func = 268435456] = "Func", ErrorRecoverySet[ErrorRecoverySet.EOF = 536870912] = "EOF", ErrorRecoverySet[ErrorRecoverySet.TypeScriptS = 1073741824] = "TypeScriptS", ErrorRecoverySet[ErrorRecoverySet.ExprStart = 520158210] = "ExprStart", ErrorRecoverySet[ErrorRecoverySet.StmtStart = 1608580098] = "StmtStart", ErrorRecoverySet[ErrorRecoverySet.Postfix = 49280] = "Postfix"; - let AllowedElements; - (AllowedElements = AllowedElements = TypeScript1.AllowedElements || (TypeScript1.AllowedElements = {}))[AllowedElements.None = 0] = "None", AllowedElements[AllowedElements.ModuleDeclarations = 4] = "ModuleDeclarations", AllowedElements[AllowedElements.ClassDeclarations = 8] = "ClassDeclarations", AllowedElements[AllowedElements.InterfaceDeclarations = 16] = "InterfaceDeclarations", AllowedElements[AllowedElements.AmbientDeclarations = 1024] = "AmbientDeclarations", AllowedElements[AllowedElements.Properties = 2048] = "Properties", AllowedElements[AllowedElements.Global = 1052] = "Global", AllowedElements[AllowedElements.QuickParse = 3100] = "QuickParse"; - let Modifiers; - (Modifiers = Modifiers = TypeScript1.Modifiers || (TypeScript1.Modifiers = {}))[Modifiers.None = 0] = "None", Modifiers[Modifiers.Private = 1] = "Private", Modifiers[Modifiers.Public = 2] = "Public", Modifiers[Modifiers.Readonly = 4] = "Readonly", Modifiers[Modifiers.Ambient = 8] = "Ambient", Modifiers[Modifiers.Exported = 16] = "Exported", Modifiers[Modifiers.Getter = 32] = "Getter", Modifiers[Modifiers.Setter = 64] = "Setter", Modifiers[Modifiers.Static = 128] = "Static"; - let ASTFlags; - (ASTFlags = ASTFlags = TypeScript1.ASTFlags || (TypeScript1.ASTFlags = {}))[ASTFlags.None = 0] = "None", ASTFlags[ASTFlags.ExplicitSemicolon = 1] = "ExplicitSemicolon", ASTFlags[ASTFlags.AutomaticSemicolon = 2] = "AutomaticSemicolon", ASTFlags[ASTFlags.Writeable = 4] = "Writeable", ASTFlags[ASTFlags.Error = 8] = "Error", ASTFlags[ASTFlags.DotLHSPartial = 16] = "DotLHSPartial", ASTFlags[ASTFlags.DotLHS = 32] = "DotLHS", ASTFlags[ASTFlags.IsStatement = 64] = "IsStatement", ASTFlags[ASTFlags.StrictMode = 128] = "StrictMode", ASTFlags[ASTFlags.PossibleOptionalParameter = 256] = "PossibleOptionalParameter", ASTFlags[ASTFlags.ClassBaseConstructorCall = 512] = "ClassBaseConstructorCall", ASTFlags[ASTFlags.OptionalName = 1024] = "OptionalName", ASTFlags[ASTFlags.SkipNextRParen = 2048] = "SkipNextRParen"; - let DeclFlags; - (DeclFlags = DeclFlags = TypeScript1.DeclFlags || (TypeScript1.DeclFlags = {}))[DeclFlags.None = 0] = "None", DeclFlags[DeclFlags.Exported = 1] = "Exported", DeclFlags[DeclFlags.Private = 2] = "Private", DeclFlags[DeclFlags.Public = 4] = "Public", DeclFlags[DeclFlags.Ambient = 8] = "Ambient", DeclFlags[DeclFlags.Static = 16] = "Static", DeclFlags[DeclFlags.LocalStatic = 32] = "LocalStatic", DeclFlags[DeclFlags.GetAccessor = 64] = "GetAccessor", DeclFlags[DeclFlags.SetAccessor = 128] = "SetAccessor"; - let ModuleFlags; - (ModuleFlags = ModuleFlags = TypeScript1.ModuleFlags || (TypeScript1.ModuleFlags = {}))[ModuleFlags.None = 0] = "None", ModuleFlags[ModuleFlags.Exported = 1] = "Exported", ModuleFlags[ModuleFlags.Private = 2] = "Private", ModuleFlags[ModuleFlags.Public = 4] = "Public", ModuleFlags[ModuleFlags.Ambient = 8] = "Ambient", ModuleFlags[ModuleFlags.Static = 16] = "Static", ModuleFlags[ModuleFlags.LocalStatic = 32] = "LocalStatic", ModuleFlags[ModuleFlags.GetAccessor = 64] = "GetAccessor", ModuleFlags[ModuleFlags.SetAccessor = 128] = "SetAccessor", ModuleFlags[ModuleFlags.IsEnum = 256] = "IsEnum", ModuleFlags[ModuleFlags.ShouldEmitModuleDecl = 512] = "ShouldEmitModuleDecl", ModuleFlags[ModuleFlags.IsWholeFile = 1024] = "IsWholeFile", ModuleFlags[ModuleFlags.IsDynamic = 2048] = "IsDynamic", ModuleFlags[ModuleFlags.MustCaptureThis = 4096] = "MustCaptureThis"; - let SymbolFlags; - (SymbolFlags = SymbolFlags = TypeScript1.SymbolFlags || (TypeScript1.SymbolFlags = {}))[SymbolFlags.None = 0] = "None", SymbolFlags[SymbolFlags.Exported = 1] = "Exported", SymbolFlags[SymbolFlags.Private = 2] = "Private", SymbolFlags[SymbolFlags.Public = 4] = "Public", SymbolFlags[SymbolFlags.Ambient = 8] = "Ambient", SymbolFlags[SymbolFlags.Static = 16] = "Static", SymbolFlags[SymbolFlags.LocalStatic = 32] = "LocalStatic", SymbolFlags[SymbolFlags.GetAccessor = 64] = "GetAccessor", SymbolFlags[SymbolFlags.SetAccessor = 128] = "SetAccessor", SymbolFlags[SymbolFlags.Property = 256] = "Property", SymbolFlags[SymbolFlags.Readonly = 512] = "Readonly", SymbolFlags[SymbolFlags.ModuleMember = 1024] = "ModuleMember", SymbolFlags[SymbolFlags.InterfaceMember = 2048] = "InterfaceMember", SymbolFlags[SymbolFlags.ClassMember = 4096] = "ClassMember", SymbolFlags[SymbolFlags.BuiltIn = 8192] = "BuiltIn", SymbolFlags[SymbolFlags.TypeSetDuringScopeAssignment = 16384] = "TypeSetDuringScopeAssignment", SymbolFlags[SymbolFlags.Constant = 32768] = "Constant", SymbolFlags[SymbolFlags.Optional = 65536] = "Optional", SymbolFlags[SymbolFlags.RecursivelyReferenced = 131072] = "RecursivelyReferenced", SymbolFlags[SymbolFlags.Bound = 262144] = "Bound", SymbolFlags[SymbolFlags.CompilerGenerated = 524288] = "CompilerGenerated"; - let VarFlags; - (VarFlags = VarFlags = TypeScript1.VarFlags || (TypeScript1.VarFlags = {}))[VarFlags.None = 0] = "None", VarFlags[VarFlags.Exported = 1] = "Exported", VarFlags[VarFlags.Private = 2] = "Private", VarFlags[VarFlags.Public = 4] = "Public", VarFlags[VarFlags.Ambient = 8] = "Ambient", VarFlags[VarFlags.Static = 16] = "Static", VarFlags[VarFlags.LocalStatic = 32] = "LocalStatic", VarFlags[VarFlags.GetAccessor = 64] = "GetAccessor", VarFlags[VarFlags.SetAccessor = 128] = "SetAccessor", VarFlags[VarFlags.AutoInit = 256] = "AutoInit", VarFlags[VarFlags.Property = 512] = "Property", VarFlags[VarFlags.Readonly = 1024] = "Readonly", VarFlags[VarFlags.Class = 2048] = "Class", VarFlags[VarFlags.ClassProperty = 4096] = "ClassProperty", VarFlags[VarFlags.ClassBodyProperty = 8192] = "ClassBodyProperty", VarFlags[VarFlags.ClassConstructorProperty = 16384] = "ClassConstructorProperty", VarFlags[VarFlags.ClassSuperMustBeFirstCallInConstructor = 32768] = "ClassSuperMustBeFirstCallInConstructor", VarFlags[VarFlags.Constant = 65536] = "Constant", VarFlags[VarFlags.MustCaptureThis = 131072] = "MustCaptureThis"; - let FncFlags; - (FncFlags = FncFlags = TypeScript1.FncFlags || (TypeScript1.FncFlags = {}))[FncFlags.None = 0] = "None", FncFlags[FncFlags.Exported = 1] = "Exported", FncFlags[FncFlags.Private = 2] = "Private", FncFlags[FncFlags.Public = 4] = "Public", FncFlags[FncFlags.Ambient = 8] = "Ambient", FncFlags[FncFlags.Static = 16] = "Static", FncFlags[FncFlags.LocalStatic = 32] = "LocalStatic", FncFlags[FncFlags.GetAccessor = 64] = "GetAccessor", FncFlags[FncFlags.SetAccessor = 128] = "SetAccessor", FncFlags[FncFlags.Definition = 256] = "Definition", FncFlags[FncFlags.Signature = 512] = "Signature", FncFlags[FncFlags.Method = 1024] = "Method", FncFlags[FncFlags.HasReturnExpression = 2048] = "HasReturnExpression", FncFlags[FncFlags.CallMember = 4096] = "CallMember", FncFlags[FncFlags.ConstructMember = 8192] = "ConstructMember", FncFlags[FncFlags.HasSelfReference = 16384] = "HasSelfReference", FncFlags[FncFlags.IsFatArrowFunction = 32768] = "IsFatArrowFunction", FncFlags[FncFlags.IndexerMember = 65536] = "IndexerMember", FncFlags[FncFlags.IsFunctionExpression = 131072] = "IsFunctionExpression", FncFlags[FncFlags.ClassMethod = 262144] = "ClassMethod", FncFlags[FncFlags.ClassPropertyMethodExported = 524288] = "ClassPropertyMethodExported"; - let SignatureFlags; - (SignatureFlags = SignatureFlags = TypeScript1.SignatureFlags || (TypeScript1.SignatureFlags = {}))[SignatureFlags.None = 0] = "None", SignatureFlags[SignatureFlags.IsIndexer = 1] = "IsIndexer", SignatureFlags[SignatureFlags.IsStringIndexer = 2] = "IsStringIndexer", SignatureFlags[SignatureFlags.IsNumberIndexer = 4] = "IsNumberIndexer", TypeScript1.ToDeclFlags = function(fncOrVarOrSymbolOrModuleFlags) { + }, (ErrorRecoverySet = TypeScript1.ErrorRecoverySet || (TypeScript1.ErrorRecoverySet = {}))[ErrorRecoverySet.None = 0] = "None", ErrorRecoverySet[ErrorRecoverySet.Comma = 1] = "Comma", ErrorRecoverySet[ErrorRecoverySet.SColon = 2] = "SColon", ErrorRecoverySet[ErrorRecoverySet.Asg = 4] = "Asg", ErrorRecoverySet[ErrorRecoverySet.BinOp = 8] = "BinOp", ErrorRecoverySet[ErrorRecoverySet.RBrack = 16] = "RBrack", ErrorRecoverySet[ErrorRecoverySet.RCurly = 32] = "RCurly", ErrorRecoverySet[ErrorRecoverySet.RParen = 64] = "RParen", ErrorRecoverySet[ErrorRecoverySet.Dot = 128] = "Dot", ErrorRecoverySet[ErrorRecoverySet.Colon = 256] = "Colon", ErrorRecoverySet[ErrorRecoverySet.PrimType = 512] = "PrimType", ErrorRecoverySet[ErrorRecoverySet.AddOp = 1024] = "AddOp", ErrorRecoverySet[ErrorRecoverySet.LCurly = 2048] = "LCurly", ErrorRecoverySet[ErrorRecoverySet.PreOp = 4096] = "PreOp", ErrorRecoverySet[ErrorRecoverySet.RegExp = 8192] = "RegExp", ErrorRecoverySet[ErrorRecoverySet.LParen = 16384] = "LParen", ErrorRecoverySet[ErrorRecoverySet.LBrack = 32768] = "LBrack", ErrorRecoverySet[ErrorRecoverySet.Scope = 65536] = "Scope", ErrorRecoverySet[ErrorRecoverySet.In = 131072] = "In", ErrorRecoverySet[ErrorRecoverySet.SCase = 262144] = "SCase", ErrorRecoverySet[ErrorRecoverySet.Else = 524288] = "Else", ErrorRecoverySet[ErrorRecoverySet.Catch = 1048576] = "Catch", ErrorRecoverySet[ErrorRecoverySet.Var = 2097152] = "Var", ErrorRecoverySet[ErrorRecoverySet.Stmt = 4194304] = "Stmt", ErrorRecoverySet[ErrorRecoverySet.While = 8388608] = "While", ErrorRecoverySet[ErrorRecoverySet.ID = 16777216] = "ID", ErrorRecoverySet[ErrorRecoverySet.Prefix = 33554432] = "Prefix", ErrorRecoverySet[ErrorRecoverySet.Literal = 67108864] = "Literal", ErrorRecoverySet[ErrorRecoverySet.RLit = 134217728] = "RLit", ErrorRecoverySet[ErrorRecoverySet.Func = 268435456] = "Func", ErrorRecoverySet[ErrorRecoverySet.EOF = 536870912] = "EOF", ErrorRecoverySet[ErrorRecoverySet.TypeScriptS = 1073741824] = "TypeScriptS", ErrorRecoverySet[ErrorRecoverySet.ExprStart = 520158210] = "ExprStart", ErrorRecoverySet[ErrorRecoverySet.StmtStart = 1608580098] = "StmtStart", ErrorRecoverySet[ErrorRecoverySet.Postfix = 49280] = "Postfix", (AllowedElements = TypeScript1.AllowedElements || (TypeScript1.AllowedElements = {}))[AllowedElements.None = 0] = "None", AllowedElements[AllowedElements.ModuleDeclarations = 4] = "ModuleDeclarations", AllowedElements[AllowedElements.ClassDeclarations = 8] = "ClassDeclarations", AllowedElements[AllowedElements.InterfaceDeclarations = 16] = "InterfaceDeclarations", AllowedElements[AllowedElements.AmbientDeclarations = 1024] = "AmbientDeclarations", AllowedElements[AllowedElements.Properties = 2048] = "Properties", AllowedElements[AllowedElements.Global = 1052] = "Global", AllowedElements[AllowedElements.QuickParse = 3100] = "QuickParse", (Modifiers = TypeScript1.Modifiers || (TypeScript1.Modifiers = {}))[Modifiers.None = 0] = "None", Modifiers[Modifiers.Private = 1] = "Private", Modifiers[Modifiers.Public = 2] = "Public", Modifiers[Modifiers.Readonly = 4] = "Readonly", Modifiers[Modifiers.Ambient = 8] = "Ambient", Modifiers[Modifiers.Exported = 16] = "Exported", Modifiers[Modifiers.Getter = 32] = "Getter", Modifiers[Modifiers.Setter = 64] = "Setter", Modifiers[Modifiers.Static = 128] = "Static", (ASTFlags = TypeScript1.ASTFlags || (TypeScript1.ASTFlags = {}))[ASTFlags.None = 0] = "None", ASTFlags[ASTFlags.ExplicitSemicolon = 1] = "ExplicitSemicolon", ASTFlags[ASTFlags.AutomaticSemicolon = 2] = "AutomaticSemicolon", ASTFlags[ASTFlags.Writeable = 4] = "Writeable", ASTFlags[ASTFlags.Error = 8] = "Error", ASTFlags[ASTFlags.DotLHSPartial = 16] = "DotLHSPartial", ASTFlags[ASTFlags.DotLHS = 32] = "DotLHS", ASTFlags[ASTFlags.IsStatement = 64] = "IsStatement", ASTFlags[ASTFlags.StrictMode = 128] = "StrictMode", ASTFlags[ASTFlags.PossibleOptionalParameter = 256] = "PossibleOptionalParameter", ASTFlags[ASTFlags.ClassBaseConstructorCall = 512] = "ClassBaseConstructorCall", ASTFlags[ASTFlags.OptionalName = 1024] = "OptionalName", ASTFlags[ASTFlags.SkipNextRParen = 2048] = "SkipNextRParen", (DeclFlags = TypeScript1.DeclFlags || (TypeScript1.DeclFlags = {}))[DeclFlags.None = 0] = "None", DeclFlags[DeclFlags.Exported = 1] = "Exported", DeclFlags[DeclFlags.Private = 2] = "Private", DeclFlags[DeclFlags.Public = 4] = "Public", DeclFlags[DeclFlags.Ambient = 8] = "Ambient", DeclFlags[DeclFlags.Static = 16] = "Static", DeclFlags[DeclFlags.LocalStatic = 32] = "LocalStatic", DeclFlags[DeclFlags.GetAccessor = 64] = "GetAccessor", DeclFlags[DeclFlags.SetAccessor = 128] = "SetAccessor", (ModuleFlags = TypeScript1.ModuleFlags || (TypeScript1.ModuleFlags = {}))[ModuleFlags.None = 0] = "None", ModuleFlags[ModuleFlags.Exported = 1] = "Exported", ModuleFlags[ModuleFlags.Private = 2] = "Private", ModuleFlags[ModuleFlags.Public = 4] = "Public", ModuleFlags[ModuleFlags.Ambient = 8] = "Ambient", ModuleFlags[ModuleFlags.Static = 16] = "Static", ModuleFlags[ModuleFlags.LocalStatic = 32] = "LocalStatic", ModuleFlags[ModuleFlags.GetAccessor = 64] = "GetAccessor", ModuleFlags[ModuleFlags.SetAccessor = 128] = "SetAccessor", ModuleFlags[ModuleFlags.IsEnum = 256] = "IsEnum", ModuleFlags[ModuleFlags.ShouldEmitModuleDecl = 512] = "ShouldEmitModuleDecl", ModuleFlags[ModuleFlags.IsWholeFile = 1024] = "IsWholeFile", ModuleFlags[ModuleFlags.IsDynamic = 2048] = "IsDynamic", ModuleFlags[ModuleFlags.MustCaptureThis = 4096] = "MustCaptureThis", (SymbolFlags = TypeScript1.SymbolFlags || (TypeScript1.SymbolFlags = {}))[SymbolFlags.None = 0] = "None", SymbolFlags[SymbolFlags.Exported = 1] = "Exported", SymbolFlags[SymbolFlags.Private = 2] = "Private", SymbolFlags[SymbolFlags.Public = 4] = "Public", SymbolFlags[SymbolFlags.Ambient = 8] = "Ambient", SymbolFlags[SymbolFlags.Static = 16] = "Static", SymbolFlags[SymbolFlags.LocalStatic = 32] = "LocalStatic", SymbolFlags[SymbolFlags.GetAccessor = 64] = "GetAccessor", SymbolFlags[SymbolFlags.SetAccessor = 128] = "SetAccessor", SymbolFlags[SymbolFlags.Property = 256] = "Property", SymbolFlags[SymbolFlags.Readonly = 512] = "Readonly", SymbolFlags[SymbolFlags.ModuleMember = 1024] = "ModuleMember", SymbolFlags[SymbolFlags.InterfaceMember = 2048] = "InterfaceMember", SymbolFlags[SymbolFlags.ClassMember = 4096] = "ClassMember", SymbolFlags[SymbolFlags.BuiltIn = 8192] = "BuiltIn", SymbolFlags[SymbolFlags.TypeSetDuringScopeAssignment = 16384] = "TypeSetDuringScopeAssignment", SymbolFlags[SymbolFlags.Constant = 32768] = "Constant", SymbolFlags[SymbolFlags.Optional = 65536] = "Optional", SymbolFlags[SymbolFlags.RecursivelyReferenced = 131072] = "RecursivelyReferenced", SymbolFlags[SymbolFlags.Bound = 262144] = "Bound", SymbolFlags[SymbolFlags.CompilerGenerated = 524288] = "CompilerGenerated", (VarFlags = TypeScript1.VarFlags || (TypeScript1.VarFlags = {}))[VarFlags.None = 0] = "None", VarFlags[VarFlags.Exported = 1] = "Exported", VarFlags[VarFlags.Private = 2] = "Private", VarFlags[VarFlags.Public = 4] = "Public", VarFlags[VarFlags.Ambient = 8] = "Ambient", VarFlags[VarFlags.Static = 16] = "Static", VarFlags[VarFlags.LocalStatic = 32] = "LocalStatic", VarFlags[VarFlags.GetAccessor = 64] = "GetAccessor", VarFlags[VarFlags.SetAccessor = 128] = "SetAccessor", VarFlags[VarFlags.AutoInit = 256] = "AutoInit", VarFlags[VarFlags.Property = 512] = "Property", VarFlags[VarFlags.Readonly = 1024] = "Readonly", VarFlags[VarFlags.Class = 2048] = "Class", VarFlags[VarFlags.ClassProperty = 4096] = "ClassProperty", VarFlags[VarFlags.ClassBodyProperty = 8192] = "ClassBodyProperty", VarFlags[VarFlags.ClassConstructorProperty = 16384] = "ClassConstructorProperty", VarFlags[VarFlags.ClassSuperMustBeFirstCallInConstructor = 32768] = "ClassSuperMustBeFirstCallInConstructor", VarFlags[VarFlags.Constant = 65536] = "Constant", VarFlags[VarFlags.MustCaptureThis = 131072] = "MustCaptureThis", (FncFlags = TypeScript1.FncFlags || (TypeScript1.FncFlags = {}))[FncFlags.None = 0] = "None", FncFlags[FncFlags.Exported = 1] = "Exported", FncFlags[FncFlags.Private = 2] = "Private", FncFlags[FncFlags.Public = 4] = "Public", FncFlags[FncFlags.Ambient = 8] = "Ambient", FncFlags[FncFlags.Static = 16] = "Static", FncFlags[FncFlags.LocalStatic = 32] = "LocalStatic", FncFlags[FncFlags.GetAccessor = 64] = "GetAccessor", FncFlags[FncFlags.SetAccessor = 128] = "SetAccessor", FncFlags[FncFlags.Definition = 256] = "Definition", FncFlags[FncFlags.Signature = 512] = "Signature", FncFlags[FncFlags.Method = 1024] = "Method", FncFlags[FncFlags.HasReturnExpression = 2048] = "HasReturnExpression", FncFlags[FncFlags.CallMember = 4096] = "CallMember", FncFlags[FncFlags.ConstructMember = 8192] = "ConstructMember", FncFlags[FncFlags.HasSelfReference = 16384] = "HasSelfReference", FncFlags[FncFlags.IsFatArrowFunction = 32768] = "IsFatArrowFunction", FncFlags[FncFlags.IndexerMember = 65536] = "IndexerMember", FncFlags[FncFlags.IsFunctionExpression = 131072] = "IsFunctionExpression", FncFlags[FncFlags.ClassMethod = 262144] = "ClassMethod", FncFlags[FncFlags.ClassPropertyMethodExported = 524288] = "ClassPropertyMethodExported", (SignatureFlags = TypeScript1.SignatureFlags || (TypeScript1.SignatureFlags = {}))[SignatureFlags.None = 0] = "None", SignatureFlags[SignatureFlags.IsIndexer = 1] = "IsIndexer", SignatureFlags[SignatureFlags.IsStringIndexer = 2] = "IsStringIndexer", SignatureFlags[SignatureFlags.IsNumberIndexer = 4] = "IsNumberIndexer", TypeScript1.ToDeclFlags = function(fncOrVarOrSymbolOrModuleFlags) { return fncOrVarOrSymbolOrModuleFlags; - }; - let TypeFlags; - (TypeFlags = TypeFlags = TypeScript1.TypeFlags || (TypeScript1.TypeFlags = {}))[TypeFlags.None = 0] = "None", TypeFlags[TypeFlags.HasImplementation = 1] = "HasImplementation", TypeFlags[TypeFlags.HasSelfReference = 2] = "HasSelfReference", TypeFlags[TypeFlags.MergeResult = 4] = "MergeResult", TypeFlags[TypeFlags.IsEnum = 8] = "IsEnum", TypeFlags[TypeFlags.BuildingName = 16] = "BuildingName", TypeFlags[TypeFlags.HasBaseType = 32] = "HasBaseType", TypeFlags[TypeFlags.HasBaseTypeOfObject = 64] = "HasBaseTypeOfObject", TypeFlags[TypeFlags.IsClass = 128] = "IsClass"; - let TypeRelationshipFlags; - (TypeRelationshipFlags = TypeRelationshipFlags = TypeScript1.TypeRelationshipFlags || (TypeScript1.TypeRelationshipFlags = {}))[TypeRelationshipFlags.SuccessfulComparison = 0] = "SuccessfulComparison", TypeRelationshipFlags[TypeRelationshipFlags.SourceIsNullTargetIsVoidOrUndefined = 1] = "SourceIsNullTargetIsVoidOrUndefined", TypeRelationshipFlags[TypeRelationshipFlags.RequiredPropertyIsMissing = 2] = "RequiredPropertyIsMissing", TypeRelationshipFlags[TypeRelationshipFlags.IncompatibleSignatures = 4] = "IncompatibleSignatures", TypeRelationshipFlags[TypeRelationshipFlags.SourceSignatureHasTooManyParameters = 3] = "SourceSignatureHasTooManyParameters", TypeRelationshipFlags[TypeRelationshipFlags.IncompatibleReturnTypes = 16] = "IncompatibleReturnTypes", TypeRelationshipFlags[TypeRelationshipFlags.IncompatiblePropertyTypes = 32] = "IncompatiblePropertyTypes", TypeRelationshipFlags[TypeRelationshipFlags.IncompatibleParameterTypes = 64] = "IncompatibleParameterTypes"; - let CodeGenTarget; - (CodeGenTarget = CodeGenTarget = TypeScript1.CodeGenTarget || (TypeScript1.CodeGenTarget = {}))[CodeGenTarget.ES3 = 0] = "ES3", CodeGenTarget[CodeGenTarget.ES5 = 1] = "ES5"; - let ModuleGenTarget; - (ModuleGenTarget = ModuleGenTarget = TypeScript1.ModuleGenTarget || (TypeScript1.ModuleGenTarget = {}))[ModuleGenTarget.Synchronous = 0] = "Synchronous", ModuleGenTarget[ModuleGenTarget.Asynchronous = 1] = "Asynchronous", ModuleGenTarget[ModuleGenTarget.Local = 2] = "Local", TypeScript1.codeGenTarget = CodeGenTarget.ES3, TypeScript1.moduleGenTarget = ModuleGenTarget.Synchronous, TypeScript1.optimizeModuleCodeGen = !0, TypeScript1.flagsToString = function(e, flags) { + }, (TypeFlags = TypeScript1.TypeFlags || (TypeScript1.TypeFlags = {}))[TypeFlags.None = 0] = "None", TypeFlags[TypeFlags.HasImplementation = 1] = "HasImplementation", TypeFlags[TypeFlags.HasSelfReference = 2] = "HasSelfReference", TypeFlags[TypeFlags.MergeResult = 4] = "MergeResult", TypeFlags[TypeFlags.IsEnum = 8] = "IsEnum", TypeFlags[TypeFlags.BuildingName = 16] = "BuildingName", TypeFlags[TypeFlags.HasBaseType = 32] = "HasBaseType", TypeFlags[TypeFlags.HasBaseTypeOfObject = 64] = "HasBaseTypeOfObject", TypeFlags[TypeFlags.IsClass = 128] = "IsClass", (TypeRelationshipFlags = TypeScript1.TypeRelationshipFlags || (TypeScript1.TypeRelationshipFlags = {}))[TypeRelationshipFlags.SuccessfulComparison = 0] = "SuccessfulComparison", TypeRelationshipFlags[TypeRelationshipFlags.SourceIsNullTargetIsVoidOrUndefined = 1] = "SourceIsNullTargetIsVoidOrUndefined", TypeRelationshipFlags[TypeRelationshipFlags.RequiredPropertyIsMissing = 2] = "RequiredPropertyIsMissing", TypeRelationshipFlags[TypeRelationshipFlags.IncompatibleSignatures = 4] = "IncompatibleSignatures", TypeRelationshipFlags[TypeRelationshipFlags.SourceSignatureHasTooManyParameters = 3] = "SourceSignatureHasTooManyParameters", TypeRelationshipFlags[TypeRelationshipFlags.IncompatibleReturnTypes = 16] = "IncompatibleReturnTypes", TypeRelationshipFlags[TypeRelationshipFlags.IncompatiblePropertyTypes = 32] = "IncompatiblePropertyTypes", TypeRelationshipFlags[TypeRelationshipFlags.IncompatibleParameterTypes = 64] = "IncompatibleParameterTypes"; + let CodeGenTarget1; + (CodeGenTarget = CodeGenTarget1 = TypeScript1.CodeGenTarget || (TypeScript1.CodeGenTarget = {}))[CodeGenTarget.ES3 = 0] = "ES3", CodeGenTarget[CodeGenTarget.ES5 = 1] = "ES5"; + let ModuleGenTarget1; + (ModuleGenTarget = ModuleGenTarget1 = TypeScript1.ModuleGenTarget || (TypeScript1.ModuleGenTarget = {}))[ModuleGenTarget.Synchronous = 0] = "Synchronous", ModuleGenTarget[ModuleGenTarget.Asynchronous = 1] = "Asynchronous", ModuleGenTarget[ModuleGenTarget.Local = 2] = "Local", TypeScript1.codeGenTarget = CodeGenTarget1.ES3, TypeScript1.moduleGenTarget = ModuleGenTarget1.Synchronous, TypeScript1.optimizeModuleCodeGen = !0, TypeScript1.flagsToString = function(e, flags) { for(var builder = "", i = 1; i < -2147483648; i <<= 1)if ((flags & i) != 0) { for(var k in e)if (e[k] == i) { builder.length > 0 && (builder += "|"), builder += k; diff --git a/crates/swc/tests/tsc-references/parserRealSource2_es5.2.minified.js b/crates/swc/tests/tsc-references/parserRealSource2_es5.2.minified.js index 6accabed2d2..6d1e80a5561 100644 --- a/crates/swc/tests/tsc-references/parserRealSource2_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/parserRealSource2_es5.2.minified.js @@ -1,11 +1,11 @@ var TypeScript; !function(TypeScript1) { - var ErrorRecoverySet, AllowedElements, Modifiers, ASTFlags, DeclFlags, ModuleFlags, SymbolFlags, VarFlags, FncFlags, SignatureFlags, TypeFlags, TypeRelationshipFlags, CodeGenTarget, ModuleGenTarget, ErrorRecoverySet, AllowedElements, Modifiers, ASTFlags, DeclFlags, ModuleFlags, SymbolFlags, VarFlags, FncFlags, SignatureFlags, TypeFlags, TypeRelationshipFlags, CodeGenTarget, ModuleGenTarget; + var CodeGenTarget, ModuleGenTarget, ErrorRecoverySet, AllowedElements, Modifiers, ASTFlags, DeclFlags, ModuleFlags, SymbolFlags, VarFlags, FncFlags, SignatureFlags, TypeFlags, TypeRelationshipFlags, CodeGenTarget1, ModuleGenTarget1; TypeScript1.hasFlag = function(val, flag) { return (val & flag) != 0; - }, (ErrorRecoverySet = ErrorRecoverySet = TypeScript1.ErrorRecoverySet || (TypeScript1.ErrorRecoverySet = {}))[ErrorRecoverySet.None = 0] = "None", ErrorRecoverySet[ErrorRecoverySet.Comma = 1] = "Comma", ErrorRecoverySet[ErrorRecoverySet.SColon = 2] = "SColon", ErrorRecoverySet[ErrorRecoverySet.Asg = 4] = "Asg", ErrorRecoverySet[ErrorRecoverySet.BinOp = 8] = "BinOp", ErrorRecoverySet[ErrorRecoverySet.RBrack = 16] = "RBrack", ErrorRecoverySet[ErrorRecoverySet.RCurly = 32] = "RCurly", ErrorRecoverySet[ErrorRecoverySet.RParen = 64] = "RParen", ErrorRecoverySet[ErrorRecoverySet.Dot = 128] = "Dot", ErrorRecoverySet[ErrorRecoverySet.Colon = 256] = "Colon", ErrorRecoverySet[ErrorRecoverySet.PrimType = 512] = "PrimType", ErrorRecoverySet[ErrorRecoverySet.AddOp = 1024] = "AddOp", ErrorRecoverySet[ErrorRecoverySet.LCurly = 2048] = "LCurly", ErrorRecoverySet[ErrorRecoverySet.PreOp = 4096] = "PreOp", ErrorRecoverySet[ErrorRecoverySet.RegExp = 8192] = "RegExp", ErrorRecoverySet[ErrorRecoverySet.LParen = 16384] = "LParen", ErrorRecoverySet[ErrorRecoverySet.LBrack = 32768] = "LBrack", ErrorRecoverySet[ErrorRecoverySet.Scope = 65536] = "Scope", ErrorRecoverySet[ErrorRecoverySet.In = 131072] = "In", ErrorRecoverySet[ErrorRecoverySet.SCase = 262144] = "SCase", ErrorRecoverySet[ErrorRecoverySet.Else = 524288] = "Else", ErrorRecoverySet[ErrorRecoverySet.Catch = 1048576] = "Catch", ErrorRecoverySet[ErrorRecoverySet.Var = 2097152] = "Var", ErrorRecoverySet[ErrorRecoverySet.Stmt = 4194304] = "Stmt", ErrorRecoverySet[ErrorRecoverySet.While = 8388608] = "While", ErrorRecoverySet[ErrorRecoverySet.ID = 16777216] = "ID", ErrorRecoverySet[ErrorRecoverySet.Prefix = 33554432] = "Prefix", ErrorRecoverySet[ErrorRecoverySet.Literal = 67108864] = "Literal", ErrorRecoverySet[ErrorRecoverySet.RLit = 134217728] = "RLit", ErrorRecoverySet[ErrorRecoverySet.Func = 268435456] = "Func", ErrorRecoverySet[ErrorRecoverySet.EOF = 536870912] = "EOF", ErrorRecoverySet[ErrorRecoverySet.TypeScriptS = 1073741824] = "TypeScriptS", ErrorRecoverySet[ErrorRecoverySet.ExprStart = 520158210] = "ExprStart", ErrorRecoverySet[ErrorRecoverySet.StmtStart = 1608580098] = "StmtStart", ErrorRecoverySet[ErrorRecoverySet.Postfix = 49280] = "Postfix", (AllowedElements = AllowedElements = TypeScript1.AllowedElements || (TypeScript1.AllowedElements = {}))[AllowedElements.None = 0] = "None", AllowedElements[AllowedElements.ModuleDeclarations = 4] = "ModuleDeclarations", AllowedElements[AllowedElements.ClassDeclarations = 8] = "ClassDeclarations", AllowedElements[AllowedElements.InterfaceDeclarations = 16] = "InterfaceDeclarations", AllowedElements[AllowedElements.AmbientDeclarations = 1024] = "AmbientDeclarations", AllowedElements[AllowedElements.Properties = 2048] = "Properties", AllowedElements[AllowedElements.Global = 1052] = "Global", AllowedElements[AllowedElements.QuickParse = 3100] = "QuickParse", (Modifiers = Modifiers = TypeScript1.Modifiers || (TypeScript1.Modifiers = {}))[Modifiers.None = 0] = "None", Modifiers[Modifiers.Private = 1] = "Private", Modifiers[Modifiers.Public = 2] = "Public", Modifiers[Modifiers.Readonly = 4] = "Readonly", Modifiers[Modifiers.Ambient = 8] = "Ambient", Modifiers[Modifiers.Exported = 16] = "Exported", Modifiers[Modifiers.Getter = 32] = "Getter", Modifiers[Modifiers.Setter = 64] = "Setter", Modifiers[Modifiers.Static = 128] = "Static", (ASTFlags = ASTFlags = TypeScript1.ASTFlags || (TypeScript1.ASTFlags = {}))[ASTFlags.None = 0] = "None", ASTFlags[ASTFlags.ExplicitSemicolon = 1] = "ExplicitSemicolon", ASTFlags[ASTFlags.AutomaticSemicolon = 2] = "AutomaticSemicolon", ASTFlags[ASTFlags.Writeable = 4] = "Writeable", ASTFlags[ASTFlags.Error = 8] = "Error", ASTFlags[ASTFlags.DotLHSPartial = 16] = "DotLHSPartial", ASTFlags[ASTFlags.DotLHS = 32] = "DotLHS", ASTFlags[ASTFlags.IsStatement = 64] = "IsStatement", ASTFlags[ASTFlags.StrictMode = 128] = "StrictMode", ASTFlags[ASTFlags.PossibleOptionalParameter = 256] = "PossibleOptionalParameter", ASTFlags[ASTFlags.ClassBaseConstructorCall = 512] = "ClassBaseConstructorCall", ASTFlags[ASTFlags.OptionalName = 1024] = "OptionalName", ASTFlags[ASTFlags.SkipNextRParen = 2048] = "SkipNextRParen", (DeclFlags = DeclFlags = TypeScript1.DeclFlags || (TypeScript1.DeclFlags = {}))[DeclFlags.None = 0] = "None", DeclFlags[DeclFlags.Exported = 1] = "Exported", DeclFlags[DeclFlags.Private = 2] = "Private", DeclFlags[DeclFlags.Public = 4] = "Public", DeclFlags[DeclFlags.Ambient = 8] = "Ambient", DeclFlags[DeclFlags.Static = 16] = "Static", DeclFlags[DeclFlags.LocalStatic = 32] = "LocalStatic", DeclFlags[DeclFlags.GetAccessor = 64] = "GetAccessor", DeclFlags[DeclFlags.SetAccessor = 128] = "SetAccessor", (ModuleFlags = ModuleFlags = TypeScript1.ModuleFlags || (TypeScript1.ModuleFlags = {}))[ModuleFlags.None = 0] = "None", ModuleFlags[ModuleFlags.Exported = 1] = "Exported", ModuleFlags[ModuleFlags.Private = 2] = "Private", ModuleFlags[ModuleFlags.Public = 4] = "Public", ModuleFlags[ModuleFlags.Ambient = 8] = "Ambient", ModuleFlags[ModuleFlags.Static = 16] = "Static", ModuleFlags[ModuleFlags.LocalStatic = 32] = "LocalStatic", ModuleFlags[ModuleFlags.GetAccessor = 64] = "GetAccessor", ModuleFlags[ModuleFlags.SetAccessor = 128] = "SetAccessor", ModuleFlags[ModuleFlags.IsEnum = 256] = "IsEnum", ModuleFlags[ModuleFlags.ShouldEmitModuleDecl = 512] = "ShouldEmitModuleDecl", ModuleFlags[ModuleFlags.IsWholeFile = 1024] = "IsWholeFile", ModuleFlags[ModuleFlags.IsDynamic = 2048] = "IsDynamic", ModuleFlags[ModuleFlags.MustCaptureThis = 4096] = "MustCaptureThis", (SymbolFlags = SymbolFlags = TypeScript1.SymbolFlags || (TypeScript1.SymbolFlags = {}))[SymbolFlags.None = 0] = "None", SymbolFlags[SymbolFlags.Exported = 1] = "Exported", SymbolFlags[SymbolFlags.Private = 2] = "Private", SymbolFlags[SymbolFlags.Public = 4] = "Public", SymbolFlags[SymbolFlags.Ambient = 8] = "Ambient", SymbolFlags[SymbolFlags.Static = 16] = "Static", SymbolFlags[SymbolFlags.LocalStatic = 32] = "LocalStatic", SymbolFlags[SymbolFlags.GetAccessor = 64] = "GetAccessor", SymbolFlags[SymbolFlags.SetAccessor = 128] = "SetAccessor", SymbolFlags[SymbolFlags.Property = 256] = "Property", SymbolFlags[SymbolFlags.Readonly = 512] = "Readonly", SymbolFlags[SymbolFlags.ModuleMember = 1024] = "ModuleMember", SymbolFlags[SymbolFlags.InterfaceMember = 2048] = "InterfaceMember", SymbolFlags[SymbolFlags.ClassMember = 4096] = "ClassMember", SymbolFlags[SymbolFlags.BuiltIn = 8192] = "BuiltIn", SymbolFlags[SymbolFlags.TypeSetDuringScopeAssignment = 16384] = "TypeSetDuringScopeAssignment", SymbolFlags[SymbolFlags.Constant = 32768] = "Constant", SymbolFlags[SymbolFlags.Optional = 65536] = "Optional", SymbolFlags[SymbolFlags.RecursivelyReferenced = 131072] = "RecursivelyReferenced", SymbolFlags[SymbolFlags.Bound = 262144] = "Bound", SymbolFlags[SymbolFlags.CompilerGenerated = 524288] = "CompilerGenerated", (VarFlags = VarFlags = TypeScript1.VarFlags || (TypeScript1.VarFlags = {}))[VarFlags.None = 0] = "None", VarFlags[VarFlags.Exported = 1] = "Exported", VarFlags[VarFlags.Private = 2] = "Private", VarFlags[VarFlags.Public = 4] = "Public", VarFlags[VarFlags.Ambient = 8] = "Ambient", VarFlags[VarFlags.Static = 16] = "Static", VarFlags[VarFlags.LocalStatic = 32] = "LocalStatic", VarFlags[VarFlags.GetAccessor = 64] = "GetAccessor", VarFlags[VarFlags.SetAccessor = 128] = "SetAccessor", VarFlags[VarFlags.AutoInit = 256] = "AutoInit", VarFlags[VarFlags.Property = 512] = "Property", VarFlags[VarFlags.Readonly = 1024] = "Readonly", VarFlags[VarFlags.Class = 2048] = "Class", VarFlags[VarFlags.ClassProperty = 4096] = "ClassProperty", VarFlags[VarFlags.ClassBodyProperty = 8192] = "ClassBodyProperty", VarFlags[VarFlags.ClassConstructorProperty = 16384] = "ClassConstructorProperty", VarFlags[VarFlags.ClassSuperMustBeFirstCallInConstructor = 32768] = "ClassSuperMustBeFirstCallInConstructor", VarFlags[VarFlags.Constant = 65536] = "Constant", VarFlags[VarFlags.MustCaptureThis = 131072] = "MustCaptureThis", (FncFlags = FncFlags = TypeScript1.FncFlags || (TypeScript1.FncFlags = {}))[FncFlags.None = 0] = "None", FncFlags[FncFlags.Exported = 1] = "Exported", FncFlags[FncFlags.Private = 2] = "Private", FncFlags[FncFlags.Public = 4] = "Public", FncFlags[FncFlags.Ambient = 8] = "Ambient", FncFlags[FncFlags.Static = 16] = "Static", FncFlags[FncFlags.LocalStatic = 32] = "LocalStatic", FncFlags[FncFlags.GetAccessor = 64] = "GetAccessor", FncFlags[FncFlags.SetAccessor = 128] = "SetAccessor", FncFlags[FncFlags.Definition = 256] = "Definition", FncFlags[FncFlags.Signature = 512] = "Signature", FncFlags[FncFlags.Method = 1024] = "Method", FncFlags[FncFlags.HasReturnExpression = 2048] = "HasReturnExpression", FncFlags[FncFlags.CallMember = 4096] = "CallMember", FncFlags[FncFlags.ConstructMember = 8192] = "ConstructMember", FncFlags[FncFlags.HasSelfReference = 16384] = "HasSelfReference", FncFlags[FncFlags.IsFatArrowFunction = 32768] = "IsFatArrowFunction", FncFlags[FncFlags.IndexerMember = 65536] = "IndexerMember", FncFlags[FncFlags.IsFunctionExpression = 131072] = "IsFunctionExpression", FncFlags[FncFlags.ClassMethod = 262144] = "ClassMethod", FncFlags[FncFlags.ClassPropertyMethodExported = 524288] = "ClassPropertyMethodExported", (SignatureFlags = SignatureFlags = TypeScript1.SignatureFlags || (TypeScript1.SignatureFlags = {}))[SignatureFlags.None = 0] = "None", SignatureFlags[SignatureFlags.IsIndexer = 1] = "IsIndexer", SignatureFlags[SignatureFlags.IsStringIndexer = 2] = "IsStringIndexer", SignatureFlags[SignatureFlags.IsNumberIndexer = 4] = "IsNumberIndexer", TypeScript1.ToDeclFlags = function(fncOrVarOrSymbolOrModuleFlags) { + }, (ErrorRecoverySet = TypeScript1.ErrorRecoverySet || (TypeScript1.ErrorRecoverySet = {}))[ErrorRecoverySet.None = 0] = "None", ErrorRecoverySet[ErrorRecoverySet.Comma = 1] = "Comma", ErrorRecoverySet[ErrorRecoverySet.SColon = 2] = "SColon", ErrorRecoverySet[ErrorRecoverySet.Asg = 4] = "Asg", ErrorRecoverySet[ErrorRecoverySet.BinOp = 8] = "BinOp", ErrorRecoverySet[ErrorRecoverySet.RBrack = 16] = "RBrack", ErrorRecoverySet[ErrorRecoverySet.RCurly = 32] = "RCurly", ErrorRecoverySet[ErrorRecoverySet.RParen = 64] = "RParen", ErrorRecoverySet[ErrorRecoverySet.Dot = 128] = "Dot", ErrorRecoverySet[ErrorRecoverySet.Colon = 256] = "Colon", ErrorRecoverySet[ErrorRecoverySet.PrimType = 512] = "PrimType", ErrorRecoverySet[ErrorRecoverySet.AddOp = 1024] = "AddOp", ErrorRecoverySet[ErrorRecoverySet.LCurly = 2048] = "LCurly", ErrorRecoverySet[ErrorRecoverySet.PreOp = 4096] = "PreOp", ErrorRecoverySet[ErrorRecoverySet.RegExp = 8192] = "RegExp", ErrorRecoverySet[ErrorRecoverySet.LParen = 16384] = "LParen", ErrorRecoverySet[ErrorRecoverySet.LBrack = 32768] = "LBrack", ErrorRecoverySet[ErrorRecoverySet.Scope = 65536] = "Scope", ErrorRecoverySet[ErrorRecoverySet.In = 131072] = "In", ErrorRecoverySet[ErrorRecoverySet.SCase = 262144] = "SCase", ErrorRecoverySet[ErrorRecoverySet.Else = 524288] = "Else", ErrorRecoverySet[ErrorRecoverySet.Catch = 1048576] = "Catch", ErrorRecoverySet[ErrorRecoverySet.Var = 2097152] = "Var", ErrorRecoverySet[ErrorRecoverySet.Stmt = 4194304] = "Stmt", ErrorRecoverySet[ErrorRecoverySet.While = 8388608] = "While", ErrorRecoverySet[ErrorRecoverySet.ID = 16777216] = "ID", ErrorRecoverySet[ErrorRecoverySet.Prefix = 33554432] = "Prefix", ErrorRecoverySet[ErrorRecoverySet.Literal = 67108864] = "Literal", ErrorRecoverySet[ErrorRecoverySet.RLit = 134217728] = "RLit", ErrorRecoverySet[ErrorRecoverySet.Func = 268435456] = "Func", ErrorRecoverySet[ErrorRecoverySet.EOF = 536870912] = "EOF", ErrorRecoverySet[ErrorRecoverySet.TypeScriptS = 1073741824] = "TypeScriptS", ErrorRecoverySet[ErrorRecoverySet.ExprStart = 520158210] = "ExprStart", ErrorRecoverySet[ErrorRecoverySet.StmtStart = 1608580098] = "StmtStart", ErrorRecoverySet[ErrorRecoverySet.Postfix = 49280] = "Postfix", (AllowedElements = TypeScript1.AllowedElements || (TypeScript1.AllowedElements = {}))[AllowedElements.None = 0] = "None", AllowedElements[AllowedElements.ModuleDeclarations = 4] = "ModuleDeclarations", AllowedElements[AllowedElements.ClassDeclarations = 8] = "ClassDeclarations", AllowedElements[AllowedElements.InterfaceDeclarations = 16] = "InterfaceDeclarations", AllowedElements[AllowedElements.AmbientDeclarations = 1024] = "AmbientDeclarations", AllowedElements[AllowedElements.Properties = 2048] = "Properties", AllowedElements[AllowedElements.Global = 1052] = "Global", AllowedElements[AllowedElements.QuickParse = 3100] = "QuickParse", (Modifiers = TypeScript1.Modifiers || (TypeScript1.Modifiers = {}))[Modifiers.None = 0] = "None", Modifiers[Modifiers.Private = 1] = "Private", Modifiers[Modifiers.Public = 2] = "Public", Modifiers[Modifiers.Readonly = 4] = "Readonly", Modifiers[Modifiers.Ambient = 8] = "Ambient", Modifiers[Modifiers.Exported = 16] = "Exported", Modifiers[Modifiers.Getter = 32] = "Getter", Modifiers[Modifiers.Setter = 64] = "Setter", Modifiers[Modifiers.Static = 128] = "Static", (ASTFlags = TypeScript1.ASTFlags || (TypeScript1.ASTFlags = {}))[ASTFlags.None = 0] = "None", ASTFlags[ASTFlags.ExplicitSemicolon = 1] = "ExplicitSemicolon", ASTFlags[ASTFlags.AutomaticSemicolon = 2] = "AutomaticSemicolon", ASTFlags[ASTFlags.Writeable = 4] = "Writeable", ASTFlags[ASTFlags.Error = 8] = "Error", ASTFlags[ASTFlags.DotLHSPartial = 16] = "DotLHSPartial", ASTFlags[ASTFlags.DotLHS = 32] = "DotLHS", ASTFlags[ASTFlags.IsStatement = 64] = "IsStatement", ASTFlags[ASTFlags.StrictMode = 128] = "StrictMode", ASTFlags[ASTFlags.PossibleOptionalParameter = 256] = "PossibleOptionalParameter", ASTFlags[ASTFlags.ClassBaseConstructorCall = 512] = "ClassBaseConstructorCall", ASTFlags[ASTFlags.OptionalName = 1024] = "OptionalName", ASTFlags[ASTFlags.SkipNextRParen = 2048] = "SkipNextRParen", (DeclFlags = TypeScript1.DeclFlags || (TypeScript1.DeclFlags = {}))[DeclFlags.None = 0] = "None", DeclFlags[DeclFlags.Exported = 1] = "Exported", DeclFlags[DeclFlags.Private = 2] = "Private", DeclFlags[DeclFlags.Public = 4] = "Public", DeclFlags[DeclFlags.Ambient = 8] = "Ambient", DeclFlags[DeclFlags.Static = 16] = "Static", DeclFlags[DeclFlags.LocalStatic = 32] = "LocalStatic", DeclFlags[DeclFlags.GetAccessor = 64] = "GetAccessor", DeclFlags[DeclFlags.SetAccessor = 128] = "SetAccessor", (ModuleFlags = TypeScript1.ModuleFlags || (TypeScript1.ModuleFlags = {}))[ModuleFlags.None = 0] = "None", ModuleFlags[ModuleFlags.Exported = 1] = "Exported", ModuleFlags[ModuleFlags.Private = 2] = "Private", ModuleFlags[ModuleFlags.Public = 4] = "Public", ModuleFlags[ModuleFlags.Ambient = 8] = "Ambient", ModuleFlags[ModuleFlags.Static = 16] = "Static", ModuleFlags[ModuleFlags.LocalStatic = 32] = "LocalStatic", ModuleFlags[ModuleFlags.GetAccessor = 64] = "GetAccessor", ModuleFlags[ModuleFlags.SetAccessor = 128] = "SetAccessor", ModuleFlags[ModuleFlags.IsEnum = 256] = "IsEnum", ModuleFlags[ModuleFlags.ShouldEmitModuleDecl = 512] = "ShouldEmitModuleDecl", ModuleFlags[ModuleFlags.IsWholeFile = 1024] = "IsWholeFile", ModuleFlags[ModuleFlags.IsDynamic = 2048] = "IsDynamic", ModuleFlags[ModuleFlags.MustCaptureThis = 4096] = "MustCaptureThis", (SymbolFlags = TypeScript1.SymbolFlags || (TypeScript1.SymbolFlags = {}))[SymbolFlags.None = 0] = "None", SymbolFlags[SymbolFlags.Exported = 1] = "Exported", SymbolFlags[SymbolFlags.Private = 2] = "Private", SymbolFlags[SymbolFlags.Public = 4] = "Public", SymbolFlags[SymbolFlags.Ambient = 8] = "Ambient", SymbolFlags[SymbolFlags.Static = 16] = "Static", SymbolFlags[SymbolFlags.LocalStatic = 32] = "LocalStatic", SymbolFlags[SymbolFlags.GetAccessor = 64] = "GetAccessor", SymbolFlags[SymbolFlags.SetAccessor = 128] = "SetAccessor", SymbolFlags[SymbolFlags.Property = 256] = "Property", SymbolFlags[SymbolFlags.Readonly = 512] = "Readonly", SymbolFlags[SymbolFlags.ModuleMember = 1024] = "ModuleMember", SymbolFlags[SymbolFlags.InterfaceMember = 2048] = "InterfaceMember", SymbolFlags[SymbolFlags.ClassMember = 4096] = "ClassMember", SymbolFlags[SymbolFlags.BuiltIn = 8192] = "BuiltIn", SymbolFlags[SymbolFlags.TypeSetDuringScopeAssignment = 16384] = "TypeSetDuringScopeAssignment", SymbolFlags[SymbolFlags.Constant = 32768] = "Constant", SymbolFlags[SymbolFlags.Optional = 65536] = "Optional", SymbolFlags[SymbolFlags.RecursivelyReferenced = 131072] = "RecursivelyReferenced", SymbolFlags[SymbolFlags.Bound = 262144] = "Bound", SymbolFlags[SymbolFlags.CompilerGenerated = 524288] = "CompilerGenerated", (VarFlags = TypeScript1.VarFlags || (TypeScript1.VarFlags = {}))[VarFlags.None = 0] = "None", VarFlags[VarFlags.Exported = 1] = "Exported", VarFlags[VarFlags.Private = 2] = "Private", VarFlags[VarFlags.Public = 4] = "Public", VarFlags[VarFlags.Ambient = 8] = "Ambient", VarFlags[VarFlags.Static = 16] = "Static", VarFlags[VarFlags.LocalStatic = 32] = "LocalStatic", VarFlags[VarFlags.GetAccessor = 64] = "GetAccessor", VarFlags[VarFlags.SetAccessor = 128] = "SetAccessor", VarFlags[VarFlags.AutoInit = 256] = "AutoInit", VarFlags[VarFlags.Property = 512] = "Property", VarFlags[VarFlags.Readonly = 1024] = "Readonly", VarFlags[VarFlags.Class = 2048] = "Class", VarFlags[VarFlags.ClassProperty = 4096] = "ClassProperty", VarFlags[VarFlags.ClassBodyProperty = 8192] = "ClassBodyProperty", VarFlags[VarFlags.ClassConstructorProperty = 16384] = "ClassConstructorProperty", VarFlags[VarFlags.ClassSuperMustBeFirstCallInConstructor = 32768] = "ClassSuperMustBeFirstCallInConstructor", VarFlags[VarFlags.Constant = 65536] = "Constant", VarFlags[VarFlags.MustCaptureThis = 131072] = "MustCaptureThis", (FncFlags = TypeScript1.FncFlags || (TypeScript1.FncFlags = {}))[FncFlags.None = 0] = "None", FncFlags[FncFlags.Exported = 1] = "Exported", FncFlags[FncFlags.Private = 2] = "Private", FncFlags[FncFlags.Public = 4] = "Public", FncFlags[FncFlags.Ambient = 8] = "Ambient", FncFlags[FncFlags.Static = 16] = "Static", FncFlags[FncFlags.LocalStatic = 32] = "LocalStatic", FncFlags[FncFlags.GetAccessor = 64] = "GetAccessor", FncFlags[FncFlags.SetAccessor = 128] = "SetAccessor", FncFlags[FncFlags.Definition = 256] = "Definition", FncFlags[FncFlags.Signature = 512] = "Signature", FncFlags[FncFlags.Method = 1024] = "Method", FncFlags[FncFlags.HasReturnExpression = 2048] = "HasReturnExpression", FncFlags[FncFlags.CallMember = 4096] = "CallMember", FncFlags[FncFlags.ConstructMember = 8192] = "ConstructMember", FncFlags[FncFlags.HasSelfReference = 16384] = "HasSelfReference", FncFlags[FncFlags.IsFatArrowFunction = 32768] = "IsFatArrowFunction", FncFlags[FncFlags.IndexerMember = 65536] = "IndexerMember", FncFlags[FncFlags.IsFunctionExpression = 131072] = "IsFunctionExpression", FncFlags[FncFlags.ClassMethod = 262144] = "ClassMethod", FncFlags[FncFlags.ClassPropertyMethodExported = 524288] = "ClassPropertyMethodExported", (SignatureFlags = TypeScript1.SignatureFlags || (TypeScript1.SignatureFlags = {}))[SignatureFlags.None = 0] = "None", SignatureFlags[SignatureFlags.IsIndexer = 1] = "IsIndexer", SignatureFlags[SignatureFlags.IsStringIndexer = 2] = "IsStringIndexer", SignatureFlags[SignatureFlags.IsNumberIndexer = 4] = "IsNumberIndexer", TypeScript1.ToDeclFlags = function(fncOrVarOrSymbolOrModuleFlags) { return fncOrVarOrSymbolOrModuleFlags; - }, (TypeFlags = TypeFlags = TypeScript1.TypeFlags || (TypeScript1.TypeFlags = {}))[TypeFlags.None = 0] = "None", TypeFlags[TypeFlags.HasImplementation = 1] = "HasImplementation", TypeFlags[TypeFlags.HasSelfReference = 2] = "HasSelfReference", TypeFlags[TypeFlags.MergeResult = 4] = "MergeResult", TypeFlags[TypeFlags.IsEnum = 8] = "IsEnum", TypeFlags[TypeFlags.BuildingName = 16] = "BuildingName", TypeFlags[TypeFlags.HasBaseType = 32] = "HasBaseType", TypeFlags[TypeFlags.HasBaseTypeOfObject = 64] = "HasBaseTypeOfObject", TypeFlags[TypeFlags.IsClass = 128] = "IsClass", (TypeRelationshipFlags = TypeRelationshipFlags = TypeScript1.TypeRelationshipFlags || (TypeScript1.TypeRelationshipFlags = {}))[TypeRelationshipFlags.SuccessfulComparison = 0] = "SuccessfulComparison", TypeRelationshipFlags[TypeRelationshipFlags.SourceIsNullTargetIsVoidOrUndefined = 1] = "SourceIsNullTargetIsVoidOrUndefined", TypeRelationshipFlags[TypeRelationshipFlags.RequiredPropertyIsMissing = 2] = "RequiredPropertyIsMissing", TypeRelationshipFlags[TypeRelationshipFlags.IncompatibleSignatures = 4] = "IncompatibleSignatures", TypeRelationshipFlags[TypeRelationshipFlags.SourceSignatureHasTooManyParameters = 3] = "SourceSignatureHasTooManyParameters", TypeRelationshipFlags[TypeRelationshipFlags.IncompatibleReturnTypes = 16] = "IncompatibleReturnTypes", TypeRelationshipFlags[TypeRelationshipFlags.IncompatiblePropertyTypes = 32] = "IncompatiblePropertyTypes", TypeRelationshipFlags[TypeRelationshipFlags.IncompatibleParameterTypes = 64] = "IncompatibleParameterTypes", (CodeGenTarget = CodeGenTarget = TypeScript1.CodeGenTarget || (TypeScript1.CodeGenTarget = {}))[CodeGenTarget.ES3 = 0] = "ES3", CodeGenTarget[CodeGenTarget.ES5 = 1] = "ES5", (ModuleGenTarget = ModuleGenTarget = TypeScript1.ModuleGenTarget || (TypeScript1.ModuleGenTarget = {}))[ModuleGenTarget.Synchronous = 0] = "Synchronous", ModuleGenTarget[ModuleGenTarget.Asynchronous = 1] = "Asynchronous", ModuleGenTarget[ModuleGenTarget.Local = 2] = "Local", TypeScript1.codeGenTarget = CodeGenTarget.ES3, TypeScript1.moduleGenTarget = ModuleGenTarget.Synchronous, TypeScript1.optimizeModuleCodeGen = !0, TypeScript1.flagsToString = function(e, flags) { + }, (TypeFlags = TypeScript1.TypeFlags || (TypeScript1.TypeFlags = {}))[TypeFlags.None = 0] = "None", TypeFlags[TypeFlags.HasImplementation = 1] = "HasImplementation", TypeFlags[TypeFlags.HasSelfReference = 2] = "HasSelfReference", TypeFlags[TypeFlags.MergeResult = 4] = "MergeResult", TypeFlags[TypeFlags.IsEnum = 8] = "IsEnum", TypeFlags[TypeFlags.BuildingName = 16] = "BuildingName", TypeFlags[TypeFlags.HasBaseType = 32] = "HasBaseType", TypeFlags[TypeFlags.HasBaseTypeOfObject = 64] = "HasBaseTypeOfObject", TypeFlags[TypeFlags.IsClass = 128] = "IsClass", (TypeRelationshipFlags = TypeScript1.TypeRelationshipFlags || (TypeScript1.TypeRelationshipFlags = {}))[TypeRelationshipFlags.SuccessfulComparison = 0] = "SuccessfulComparison", TypeRelationshipFlags[TypeRelationshipFlags.SourceIsNullTargetIsVoidOrUndefined = 1] = "SourceIsNullTargetIsVoidOrUndefined", TypeRelationshipFlags[TypeRelationshipFlags.RequiredPropertyIsMissing = 2] = "RequiredPropertyIsMissing", TypeRelationshipFlags[TypeRelationshipFlags.IncompatibleSignatures = 4] = "IncompatibleSignatures", TypeRelationshipFlags[TypeRelationshipFlags.SourceSignatureHasTooManyParameters = 3] = "SourceSignatureHasTooManyParameters", TypeRelationshipFlags[TypeRelationshipFlags.IncompatibleReturnTypes = 16] = "IncompatibleReturnTypes", TypeRelationshipFlags[TypeRelationshipFlags.IncompatiblePropertyTypes = 32] = "IncompatiblePropertyTypes", TypeRelationshipFlags[TypeRelationshipFlags.IncompatibleParameterTypes = 64] = "IncompatibleParameterTypes", (CodeGenTarget1 = CodeGenTarget = TypeScript1.CodeGenTarget || (TypeScript1.CodeGenTarget = {}))[CodeGenTarget1.ES3 = 0] = "ES3", CodeGenTarget1[CodeGenTarget1.ES5 = 1] = "ES5", (ModuleGenTarget1 = ModuleGenTarget = TypeScript1.ModuleGenTarget || (TypeScript1.ModuleGenTarget = {}))[ModuleGenTarget1.Synchronous = 0] = "Synchronous", ModuleGenTarget1[ModuleGenTarget1.Asynchronous = 1] = "Asynchronous", ModuleGenTarget1[ModuleGenTarget1.Local = 2] = "Local", TypeScript1.codeGenTarget = CodeGenTarget.ES3, TypeScript1.moduleGenTarget = ModuleGenTarget.Synchronous, TypeScript1.optimizeModuleCodeGen = !0, TypeScript1.flagsToString = function(e, flags) { for(var builder = "", i = 1; i < -2147483648; i <<= 1)if ((flags & i) != 0) { for(var k in e)if (e[k] == i) { builder.length > 0 && (builder += "|"), builder += k; diff --git a/crates/swc/tests/tsc-references/parserRealSource3_es2015.2.minified.js b/crates/swc/tests/tsc-references/parserRealSource3_es2015.2.minified.js index 815607c39e2..49cefa72701 100644 --- a/crates/swc/tests/tsc-references/parserRealSource3_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/parserRealSource3_es2015.2.minified.js @@ -1,6 +1,5 @@ var TypeScript; !function(TypeScript1) { var NodeType; - let NodeType; - (NodeType = NodeType = TypeScript1.NodeType || (TypeScript1.NodeType = {}))[NodeType.None = 0] = "None", NodeType[NodeType.Empty = 1] = "Empty", NodeType[NodeType.EmptyExpr = 2] = "EmptyExpr", NodeType[NodeType.True = 3] = "True", NodeType[NodeType.False = 4] = "False", NodeType[NodeType.This = 5] = "This", NodeType[NodeType.Super = 6] = "Super", NodeType[NodeType.QString = 7] = "QString", NodeType[NodeType.Regex = 8] = "Regex", NodeType[NodeType.Null = 9] = "Null", NodeType[NodeType.ArrayLit = 10] = "ArrayLit", NodeType[NodeType.ObjectLit = 11] = "ObjectLit", NodeType[NodeType.Void = 12] = "Void", NodeType[NodeType.Comma = 13] = "Comma", NodeType[NodeType.Pos = 14] = "Pos", NodeType[NodeType.Neg = 15] = "Neg", NodeType[NodeType.Delete = 16] = "Delete", NodeType[NodeType.Await = 17] = "Await", NodeType[NodeType.In = 18] = "In", NodeType[NodeType.Dot = 19] = "Dot", NodeType[NodeType.From = 20] = "From", NodeType[NodeType.Is = 21] = "Is", NodeType[NodeType.InstOf = 22] = "InstOf", NodeType[NodeType.Typeof = 23] = "Typeof", NodeType[NodeType.NumberLit = 24] = "NumberLit", NodeType[NodeType.Name = 25] = "Name", NodeType[NodeType.TypeRef = 26] = "TypeRef", NodeType[NodeType.Index = 27] = "Index", NodeType[NodeType.Call = 28] = "Call", NodeType[NodeType.New = 29] = "New", NodeType[NodeType.Asg = 30] = "Asg", NodeType[NodeType.AsgAdd = 31] = "AsgAdd", NodeType[NodeType.AsgSub = 32] = "AsgSub", NodeType[NodeType.AsgDiv = 33] = "AsgDiv", NodeType[NodeType.AsgMul = 34] = "AsgMul", NodeType[NodeType.AsgMod = 35] = "AsgMod", NodeType[NodeType.AsgAnd = 36] = "AsgAnd", NodeType[NodeType.AsgXor = 37] = "AsgXor", NodeType[NodeType.AsgOr = 38] = "AsgOr", NodeType[NodeType.AsgLsh = 39] = "AsgLsh", NodeType[NodeType.AsgRsh = 40] = "AsgRsh", NodeType[NodeType.AsgRs2 = 41] = "AsgRs2", NodeType[NodeType.ConditionalExpression = 42] = "ConditionalExpression", NodeType[NodeType.LogOr = 43] = "LogOr", NodeType[NodeType.LogAnd = 44] = "LogAnd", NodeType[NodeType.Or = 45] = "Or", NodeType[NodeType.Xor = 46] = "Xor", NodeType[NodeType.And = 47] = "And", NodeType[NodeType.Eq = 48] = "Eq", NodeType[NodeType.Ne = 49] = "Ne", NodeType[NodeType.Eqv = 50] = "Eqv", NodeType[NodeType.NEqv = 51] = "NEqv", NodeType[NodeType.Lt = 52] = "Lt", NodeType[NodeType.Le = 53] = "Le", NodeType[NodeType.Gt = 54] = "Gt", NodeType[NodeType.Ge = 55] = "Ge", NodeType[NodeType.Add = 56] = "Add", NodeType[NodeType.Sub = 57] = "Sub", NodeType[NodeType.Mul = 58] = "Mul", NodeType[NodeType.Div = 59] = "Div", NodeType[NodeType.Mod = 60] = "Mod", NodeType[NodeType.Lsh = 61] = "Lsh", NodeType[NodeType.Rsh = 62] = "Rsh", NodeType[NodeType.Rs2 = 63] = "Rs2", NodeType[NodeType.Not = 64] = "Not", NodeType[NodeType.LogNot = 65] = "LogNot", NodeType[NodeType.IncPre = 66] = "IncPre", NodeType[NodeType.DecPre = 67] = "DecPre", NodeType[NodeType.IncPost = 68] = "IncPost", NodeType[NodeType.DecPost = 69] = "DecPost", NodeType[NodeType.TypeAssertion = 70] = "TypeAssertion", NodeType[NodeType.FuncDecl = 71] = "FuncDecl", NodeType[NodeType.Member = 72] = "Member", NodeType[NodeType.VarDecl = 73] = "VarDecl", NodeType[NodeType.ArgDecl = 74] = "ArgDecl", NodeType[NodeType.Return = 75] = "Return", NodeType[NodeType.Break = 76] = "Break", NodeType[NodeType.Continue = 77] = "Continue", NodeType[NodeType.Throw = 78] = "Throw", NodeType[NodeType.For = 79] = "For", NodeType[NodeType.ForIn = 80] = "ForIn", NodeType[NodeType.If = 81] = "If", NodeType[NodeType.While = 82] = "While", NodeType[NodeType.DoWhile = 83] = "DoWhile", NodeType[NodeType.Block = 84] = "Block", NodeType[NodeType.Case = 85] = "Case", NodeType[NodeType.Switch = 86] = "Switch", NodeType[NodeType.Try = 87] = "Try", NodeType[NodeType.TryCatch = 88] = "TryCatch", NodeType[NodeType.TryFinally = 89] = "TryFinally", NodeType[NodeType.Finally = 90] = "Finally", NodeType[NodeType.Catch = 91] = "Catch", NodeType[NodeType.List = 92] = "List", NodeType[NodeType.Script = 93] = "Script", NodeType[NodeType.ClassDeclaration = 94] = "ClassDeclaration", NodeType[NodeType.InterfaceDeclaration = 95] = "InterfaceDeclaration", NodeType[NodeType.ModuleDeclaration = 96] = "ModuleDeclaration", NodeType[NodeType.ImportDeclaration = 97] = "ImportDeclaration", NodeType[NodeType.With = 98] = "With", NodeType[NodeType.Label = 99] = "Label", NodeType[NodeType.LabeledStatement = 100] = "LabeledStatement", NodeType[NodeType.EBStart = 101] = "EBStart", NodeType[NodeType.GotoEB = 102] = "GotoEB", NodeType[NodeType.EndCode = 103] = "EndCode", NodeType[NodeType.Error = 104] = "Error", NodeType[NodeType.Comment = 105] = "Comment", NodeType[NodeType.Debugger = 106] = "Debugger", NodeType[NodeType.GeneralNode = 71] = "GeneralNode", NodeType[NodeType.LastAsg = 41] = "LastAsg"; + (NodeType = TypeScript1.NodeType || (TypeScript1.NodeType = {}))[NodeType.None = 0] = "None", NodeType[NodeType.Empty = 1] = "Empty", NodeType[NodeType.EmptyExpr = 2] = "EmptyExpr", NodeType[NodeType.True = 3] = "True", NodeType[NodeType.False = 4] = "False", NodeType[NodeType.This = 5] = "This", NodeType[NodeType.Super = 6] = "Super", NodeType[NodeType.QString = 7] = "QString", NodeType[NodeType.Regex = 8] = "Regex", NodeType[NodeType.Null = 9] = "Null", NodeType[NodeType.ArrayLit = 10] = "ArrayLit", NodeType[NodeType.ObjectLit = 11] = "ObjectLit", NodeType[NodeType.Void = 12] = "Void", NodeType[NodeType.Comma = 13] = "Comma", NodeType[NodeType.Pos = 14] = "Pos", NodeType[NodeType.Neg = 15] = "Neg", NodeType[NodeType.Delete = 16] = "Delete", NodeType[NodeType.Await = 17] = "Await", NodeType[NodeType.In = 18] = "In", NodeType[NodeType.Dot = 19] = "Dot", NodeType[NodeType.From = 20] = "From", NodeType[NodeType.Is = 21] = "Is", NodeType[NodeType.InstOf = 22] = "InstOf", NodeType[NodeType.Typeof = 23] = "Typeof", NodeType[NodeType.NumberLit = 24] = "NumberLit", NodeType[NodeType.Name = 25] = "Name", NodeType[NodeType.TypeRef = 26] = "TypeRef", NodeType[NodeType.Index = 27] = "Index", NodeType[NodeType.Call = 28] = "Call", NodeType[NodeType.New = 29] = "New", NodeType[NodeType.Asg = 30] = "Asg", NodeType[NodeType.AsgAdd = 31] = "AsgAdd", NodeType[NodeType.AsgSub = 32] = "AsgSub", NodeType[NodeType.AsgDiv = 33] = "AsgDiv", NodeType[NodeType.AsgMul = 34] = "AsgMul", NodeType[NodeType.AsgMod = 35] = "AsgMod", NodeType[NodeType.AsgAnd = 36] = "AsgAnd", NodeType[NodeType.AsgXor = 37] = "AsgXor", NodeType[NodeType.AsgOr = 38] = "AsgOr", NodeType[NodeType.AsgLsh = 39] = "AsgLsh", NodeType[NodeType.AsgRsh = 40] = "AsgRsh", NodeType[NodeType.AsgRs2 = 41] = "AsgRs2", NodeType[NodeType.ConditionalExpression = 42] = "ConditionalExpression", NodeType[NodeType.LogOr = 43] = "LogOr", NodeType[NodeType.LogAnd = 44] = "LogAnd", NodeType[NodeType.Or = 45] = "Or", NodeType[NodeType.Xor = 46] = "Xor", NodeType[NodeType.And = 47] = "And", NodeType[NodeType.Eq = 48] = "Eq", NodeType[NodeType.Ne = 49] = "Ne", NodeType[NodeType.Eqv = 50] = "Eqv", NodeType[NodeType.NEqv = 51] = "NEqv", NodeType[NodeType.Lt = 52] = "Lt", NodeType[NodeType.Le = 53] = "Le", NodeType[NodeType.Gt = 54] = "Gt", NodeType[NodeType.Ge = 55] = "Ge", NodeType[NodeType.Add = 56] = "Add", NodeType[NodeType.Sub = 57] = "Sub", NodeType[NodeType.Mul = 58] = "Mul", NodeType[NodeType.Div = 59] = "Div", NodeType[NodeType.Mod = 60] = "Mod", NodeType[NodeType.Lsh = 61] = "Lsh", NodeType[NodeType.Rsh = 62] = "Rsh", NodeType[NodeType.Rs2 = 63] = "Rs2", NodeType[NodeType.Not = 64] = "Not", NodeType[NodeType.LogNot = 65] = "LogNot", NodeType[NodeType.IncPre = 66] = "IncPre", NodeType[NodeType.DecPre = 67] = "DecPre", NodeType[NodeType.IncPost = 68] = "IncPost", NodeType[NodeType.DecPost = 69] = "DecPost", NodeType[NodeType.TypeAssertion = 70] = "TypeAssertion", NodeType[NodeType.FuncDecl = 71] = "FuncDecl", NodeType[NodeType.Member = 72] = "Member", NodeType[NodeType.VarDecl = 73] = "VarDecl", NodeType[NodeType.ArgDecl = 74] = "ArgDecl", NodeType[NodeType.Return = 75] = "Return", NodeType[NodeType.Break = 76] = "Break", NodeType[NodeType.Continue = 77] = "Continue", NodeType[NodeType.Throw = 78] = "Throw", NodeType[NodeType.For = 79] = "For", NodeType[NodeType.ForIn = 80] = "ForIn", NodeType[NodeType.If = 81] = "If", NodeType[NodeType.While = 82] = "While", NodeType[NodeType.DoWhile = 83] = "DoWhile", NodeType[NodeType.Block = 84] = "Block", NodeType[NodeType.Case = 85] = "Case", NodeType[NodeType.Switch = 86] = "Switch", NodeType[NodeType.Try = 87] = "Try", NodeType[NodeType.TryCatch = 88] = "TryCatch", NodeType[NodeType.TryFinally = 89] = "TryFinally", NodeType[NodeType.Finally = 90] = "Finally", NodeType[NodeType.Catch = 91] = "Catch", NodeType[NodeType.List = 92] = "List", NodeType[NodeType.Script = 93] = "Script", NodeType[NodeType.ClassDeclaration = 94] = "ClassDeclaration", NodeType[NodeType.InterfaceDeclaration = 95] = "InterfaceDeclaration", NodeType[NodeType.ModuleDeclaration = 96] = "ModuleDeclaration", NodeType[NodeType.ImportDeclaration = 97] = "ImportDeclaration", NodeType[NodeType.With = 98] = "With", NodeType[NodeType.Label = 99] = "Label", NodeType[NodeType.LabeledStatement = 100] = "LabeledStatement", NodeType[NodeType.EBStart = 101] = "EBStart", NodeType[NodeType.GotoEB = 102] = "GotoEB", NodeType[NodeType.EndCode = 103] = "EndCode", NodeType[NodeType.Error = 104] = "Error", NodeType[NodeType.Comment = 105] = "Comment", NodeType[NodeType.Debugger = 106] = "Debugger", NodeType[NodeType.GeneralNode = 71] = "GeneralNode", NodeType[NodeType.LastAsg = 41] = "LastAsg"; }(TypeScript || (TypeScript = {})); diff --git a/crates/swc/tests/tsc-references/parserRealSource3_es5.2.minified.js b/crates/swc/tests/tsc-references/parserRealSource3_es5.2.minified.js index 0b232d1c4ab..49cefa72701 100644 --- a/crates/swc/tests/tsc-references/parserRealSource3_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/parserRealSource3_es5.2.minified.js @@ -1,5 +1,5 @@ var TypeScript; !function(TypeScript1) { - var NodeType, NodeType; - (NodeType = NodeType = TypeScript1.NodeType || (TypeScript1.NodeType = {}))[NodeType.None = 0] = "None", NodeType[NodeType.Empty = 1] = "Empty", NodeType[NodeType.EmptyExpr = 2] = "EmptyExpr", NodeType[NodeType.True = 3] = "True", NodeType[NodeType.False = 4] = "False", NodeType[NodeType.This = 5] = "This", NodeType[NodeType.Super = 6] = "Super", NodeType[NodeType.QString = 7] = "QString", NodeType[NodeType.Regex = 8] = "Regex", NodeType[NodeType.Null = 9] = "Null", NodeType[NodeType.ArrayLit = 10] = "ArrayLit", NodeType[NodeType.ObjectLit = 11] = "ObjectLit", NodeType[NodeType.Void = 12] = "Void", NodeType[NodeType.Comma = 13] = "Comma", NodeType[NodeType.Pos = 14] = "Pos", NodeType[NodeType.Neg = 15] = "Neg", NodeType[NodeType.Delete = 16] = "Delete", NodeType[NodeType.Await = 17] = "Await", NodeType[NodeType.In = 18] = "In", NodeType[NodeType.Dot = 19] = "Dot", NodeType[NodeType.From = 20] = "From", NodeType[NodeType.Is = 21] = "Is", NodeType[NodeType.InstOf = 22] = "InstOf", NodeType[NodeType.Typeof = 23] = "Typeof", NodeType[NodeType.NumberLit = 24] = "NumberLit", NodeType[NodeType.Name = 25] = "Name", NodeType[NodeType.TypeRef = 26] = "TypeRef", NodeType[NodeType.Index = 27] = "Index", NodeType[NodeType.Call = 28] = "Call", NodeType[NodeType.New = 29] = "New", NodeType[NodeType.Asg = 30] = "Asg", NodeType[NodeType.AsgAdd = 31] = "AsgAdd", NodeType[NodeType.AsgSub = 32] = "AsgSub", NodeType[NodeType.AsgDiv = 33] = "AsgDiv", NodeType[NodeType.AsgMul = 34] = "AsgMul", NodeType[NodeType.AsgMod = 35] = "AsgMod", NodeType[NodeType.AsgAnd = 36] = "AsgAnd", NodeType[NodeType.AsgXor = 37] = "AsgXor", NodeType[NodeType.AsgOr = 38] = "AsgOr", NodeType[NodeType.AsgLsh = 39] = "AsgLsh", NodeType[NodeType.AsgRsh = 40] = "AsgRsh", NodeType[NodeType.AsgRs2 = 41] = "AsgRs2", NodeType[NodeType.ConditionalExpression = 42] = "ConditionalExpression", NodeType[NodeType.LogOr = 43] = "LogOr", NodeType[NodeType.LogAnd = 44] = "LogAnd", NodeType[NodeType.Or = 45] = "Or", NodeType[NodeType.Xor = 46] = "Xor", NodeType[NodeType.And = 47] = "And", NodeType[NodeType.Eq = 48] = "Eq", NodeType[NodeType.Ne = 49] = "Ne", NodeType[NodeType.Eqv = 50] = "Eqv", NodeType[NodeType.NEqv = 51] = "NEqv", NodeType[NodeType.Lt = 52] = "Lt", NodeType[NodeType.Le = 53] = "Le", NodeType[NodeType.Gt = 54] = "Gt", NodeType[NodeType.Ge = 55] = "Ge", NodeType[NodeType.Add = 56] = "Add", NodeType[NodeType.Sub = 57] = "Sub", NodeType[NodeType.Mul = 58] = "Mul", NodeType[NodeType.Div = 59] = "Div", NodeType[NodeType.Mod = 60] = "Mod", NodeType[NodeType.Lsh = 61] = "Lsh", NodeType[NodeType.Rsh = 62] = "Rsh", NodeType[NodeType.Rs2 = 63] = "Rs2", NodeType[NodeType.Not = 64] = "Not", NodeType[NodeType.LogNot = 65] = "LogNot", NodeType[NodeType.IncPre = 66] = "IncPre", NodeType[NodeType.DecPre = 67] = "DecPre", NodeType[NodeType.IncPost = 68] = "IncPost", NodeType[NodeType.DecPost = 69] = "DecPost", NodeType[NodeType.TypeAssertion = 70] = "TypeAssertion", NodeType[NodeType.FuncDecl = 71] = "FuncDecl", NodeType[NodeType.Member = 72] = "Member", NodeType[NodeType.VarDecl = 73] = "VarDecl", NodeType[NodeType.ArgDecl = 74] = "ArgDecl", NodeType[NodeType.Return = 75] = "Return", NodeType[NodeType.Break = 76] = "Break", NodeType[NodeType.Continue = 77] = "Continue", NodeType[NodeType.Throw = 78] = "Throw", NodeType[NodeType.For = 79] = "For", NodeType[NodeType.ForIn = 80] = "ForIn", NodeType[NodeType.If = 81] = "If", NodeType[NodeType.While = 82] = "While", NodeType[NodeType.DoWhile = 83] = "DoWhile", NodeType[NodeType.Block = 84] = "Block", NodeType[NodeType.Case = 85] = "Case", NodeType[NodeType.Switch = 86] = "Switch", NodeType[NodeType.Try = 87] = "Try", NodeType[NodeType.TryCatch = 88] = "TryCatch", NodeType[NodeType.TryFinally = 89] = "TryFinally", NodeType[NodeType.Finally = 90] = "Finally", NodeType[NodeType.Catch = 91] = "Catch", NodeType[NodeType.List = 92] = "List", NodeType[NodeType.Script = 93] = "Script", NodeType[NodeType.ClassDeclaration = 94] = "ClassDeclaration", NodeType[NodeType.InterfaceDeclaration = 95] = "InterfaceDeclaration", NodeType[NodeType.ModuleDeclaration = 96] = "ModuleDeclaration", NodeType[NodeType.ImportDeclaration = 97] = "ImportDeclaration", NodeType[NodeType.With = 98] = "With", NodeType[NodeType.Label = 99] = "Label", NodeType[NodeType.LabeledStatement = 100] = "LabeledStatement", NodeType[NodeType.EBStart = 101] = "EBStart", NodeType[NodeType.GotoEB = 102] = "GotoEB", NodeType[NodeType.EndCode = 103] = "EndCode", NodeType[NodeType.Error = 104] = "Error", NodeType[NodeType.Comment = 105] = "Comment", NodeType[NodeType.Debugger = 106] = "Debugger", NodeType[NodeType.GeneralNode = 71] = "GeneralNode", NodeType[NodeType.LastAsg = 41] = "LastAsg"; + var NodeType; + (NodeType = TypeScript1.NodeType || (TypeScript1.NodeType = {}))[NodeType.None = 0] = "None", NodeType[NodeType.Empty = 1] = "Empty", NodeType[NodeType.EmptyExpr = 2] = "EmptyExpr", NodeType[NodeType.True = 3] = "True", NodeType[NodeType.False = 4] = "False", NodeType[NodeType.This = 5] = "This", NodeType[NodeType.Super = 6] = "Super", NodeType[NodeType.QString = 7] = "QString", NodeType[NodeType.Regex = 8] = "Regex", NodeType[NodeType.Null = 9] = "Null", NodeType[NodeType.ArrayLit = 10] = "ArrayLit", NodeType[NodeType.ObjectLit = 11] = "ObjectLit", NodeType[NodeType.Void = 12] = "Void", NodeType[NodeType.Comma = 13] = "Comma", NodeType[NodeType.Pos = 14] = "Pos", NodeType[NodeType.Neg = 15] = "Neg", NodeType[NodeType.Delete = 16] = "Delete", NodeType[NodeType.Await = 17] = "Await", NodeType[NodeType.In = 18] = "In", NodeType[NodeType.Dot = 19] = "Dot", NodeType[NodeType.From = 20] = "From", NodeType[NodeType.Is = 21] = "Is", NodeType[NodeType.InstOf = 22] = "InstOf", NodeType[NodeType.Typeof = 23] = "Typeof", NodeType[NodeType.NumberLit = 24] = "NumberLit", NodeType[NodeType.Name = 25] = "Name", NodeType[NodeType.TypeRef = 26] = "TypeRef", NodeType[NodeType.Index = 27] = "Index", NodeType[NodeType.Call = 28] = "Call", NodeType[NodeType.New = 29] = "New", NodeType[NodeType.Asg = 30] = "Asg", NodeType[NodeType.AsgAdd = 31] = "AsgAdd", NodeType[NodeType.AsgSub = 32] = "AsgSub", NodeType[NodeType.AsgDiv = 33] = "AsgDiv", NodeType[NodeType.AsgMul = 34] = "AsgMul", NodeType[NodeType.AsgMod = 35] = "AsgMod", NodeType[NodeType.AsgAnd = 36] = "AsgAnd", NodeType[NodeType.AsgXor = 37] = "AsgXor", NodeType[NodeType.AsgOr = 38] = "AsgOr", NodeType[NodeType.AsgLsh = 39] = "AsgLsh", NodeType[NodeType.AsgRsh = 40] = "AsgRsh", NodeType[NodeType.AsgRs2 = 41] = "AsgRs2", NodeType[NodeType.ConditionalExpression = 42] = "ConditionalExpression", NodeType[NodeType.LogOr = 43] = "LogOr", NodeType[NodeType.LogAnd = 44] = "LogAnd", NodeType[NodeType.Or = 45] = "Or", NodeType[NodeType.Xor = 46] = "Xor", NodeType[NodeType.And = 47] = "And", NodeType[NodeType.Eq = 48] = "Eq", NodeType[NodeType.Ne = 49] = "Ne", NodeType[NodeType.Eqv = 50] = "Eqv", NodeType[NodeType.NEqv = 51] = "NEqv", NodeType[NodeType.Lt = 52] = "Lt", NodeType[NodeType.Le = 53] = "Le", NodeType[NodeType.Gt = 54] = "Gt", NodeType[NodeType.Ge = 55] = "Ge", NodeType[NodeType.Add = 56] = "Add", NodeType[NodeType.Sub = 57] = "Sub", NodeType[NodeType.Mul = 58] = "Mul", NodeType[NodeType.Div = 59] = "Div", NodeType[NodeType.Mod = 60] = "Mod", NodeType[NodeType.Lsh = 61] = "Lsh", NodeType[NodeType.Rsh = 62] = "Rsh", NodeType[NodeType.Rs2 = 63] = "Rs2", NodeType[NodeType.Not = 64] = "Not", NodeType[NodeType.LogNot = 65] = "LogNot", NodeType[NodeType.IncPre = 66] = "IncPre", NodeType[NodeType.DecPre = 67] = "DecPre", NodeType[NodeType.IncPost = 68] = "IncPost", NodeType[NodeType.DecPost = 69] = "DecPost", NodeType[NodeType.TypeAssertion = 70] = "TypeAssertion", NodeType[NodeType.FuncDecl = 71] = "FuncDecl", NodeType[NodeType.Member = 72] = "Member", NodeType[NodeType.VarDecl = 73] = "VarDecl", NodeType[NodeType.ArgDecl = 74] = "ArgDecl", NodeType[NodeType.Return = 75] = "Return", NodeType[NodeType.Break = 76] = "Break", NodeType[NodeType.Continue = 77] = "Continue", NodeType[NodeType.Throw = 78] = "Throw", NodeType[NodeType.For = 79] = "For", NodeType[NodeType.ForIn = 80] = "ForIn", NodeType[NodeType.If = 81] = "If", NodeType[NodeType.While = 82] = "While", NodeType[NodeType.DoWhile = 83] = "DoWhile", NodeType[NodeType.Block = 84] = "Block", NodeType[NodeType.Case = 85] = "Case", NodeType[NodeType.Switch = 86] = "Switch", NodeType[NodeType.Try = 87] = "Try", NodeType[NodeType.TryCatch = 88] = "TryCatch", NodeType[NodeType.TryFinally = 89] = "TryFinally", NodeType[NodeType.Finally = 90] = "Finally", NodeType[NodeType.Catch = 91] = "Catch", NodeType[NodeType.List = 92] = "List", NodeType[NodeType.Script = 93] = "Script", NodeType[NodeType.ClassDeclaration = 94] = "ClassDeclaration", NodeType[NodeType.InterfaceDeclaration = 95] = "InterfaceDeclaration", NodeType[NodeType.ModuleDeclaration = 96] = "ModuleDeclaration", NodeType[NodeType.ImportDeclaration = 97] = "ImportDeclaration", NodeType[NodeType.With = 98] = "With", NodeType[NodeType.Label = 99] = "Label", NodeType[NodeType.LabeledStatement = 100] = "LabeledStatement", NodeType[NodeType.EBStart = 101] = "EBStart", NodeType[NodeType.GotoEB = 102] = "GotoEB", NodeType[NodeType.EndCode = 103] = "EndCode", NodeType[NodeType.Error = 104] = "Error", NodeType[NodeType.Comment = 105] = "Comment", NodeType[NodeType.Debugger = 106] = "Debugger", NodeType[NodeType.GeneralNode = 71] = "GeneralNode", NodeType[NodeType.LastAsg = 41] = "LastAsg"; }(TypeScript || (TypeScript = {})); diff --git a/crates/swc_ecma_minifier/src/analyzer/mod.rs b/crates/swc_ecma_minifier/src/analyzer/mod.rs index cd346d30c9c..22304c2fe36 100644 --- a/crates/swc_ecma_minifier/src/analyzer/mod.rs +++ b/crates/swc_ecma_minifier/src/analyzer/mod.rs @@ -487,6 +487,15 @@ where n.visit_children_with(self); } + #[cfg_attr(feature = "debug", tracing::instrument(skip(self, n)))] + fn visit_class_expr(&mut self, n: &ClassExpr) { + n.visit_children_with(self); + + if let Some(id) = &n.ident { + self.declare_decl(id, true, None, false); + } + } + #[cfg_attr(feature = "debug", tracing::instrument(skip(self, n)))] fn visit_cond_expr(&mut self, n: &CondExpr) { n.test.visit_with(self); diff --git a/crates/swc_ecma_minifier/src/compress/optimize/iife.rs b/crates/swc_ecma_minifier/src/compress/optimize/iife.rs index 57403a076da..f495914b174 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/iife.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/iife.rs @@ -5,13 +5,14 @@ use swc_atoms::js_word; use swc_common::{pass::Either, util::take::Take, Mark, Spanned, SyntaxContext, DUMMY_SP}; use swc_ecma_ast::*; use swc_ecma_utils::{ - contains_arguments, contains_this_expr, ident::IdentLike, undefined, ExprFactory, Id, + contains_arguments, contains_this_expr, find_ids, ident::IdentLike, undefined, ExprFactory, Id, }; use swc_ecma_visit::VisitMutWith; use super::{util::MultiReplacer, Optimizer}; use crate::{ - compress::optimize::Ctx, + compress::optimize::{util::Remapper, Ctx}, + debug::dump, mode::Mode, util::{idents_captured_by, idents_used_by, make_number}, }; @@ -250,18 +251,17 @@ where } #[cfg_attr(feature = "debug", tracing::instrument(skip_all))] - pub(super) fn inline_vars_in_node(&mut self, n: &mut N, vars: FxHashMap>) + pub(super) fn inline_vars_in_node(&mut self, n: &mut N, mut vars: FxHashMap>) where - N: VisitMutWith, + N: for<'aa> VisitMutWith>, { if cfg!(feature = "debug") { tracing::trace!("inline: inline_vars_in_node"); } n.visit_mut_with(&mut MultiReplacer { - vars, + vars: &mut vars, changed: false, - clone: false, }); } @@ -384,8 +384,7 @@ where let new_ctxt = SyntaxContext::empty().apply_mark(Mark::fresh(Mark::root())); for p in param_ids.iter() { - let new = Ident::new(p.sym.clone(), p.span.with_ctxt(new_ctxt)); - remap.insert(p.to_id(), Box::new(Expr::Ident(new))); + remap.insert(p.to_id(), new_ctxt); } { @@ -437,10 +436,10 @@ where } } body.visit_mut_with(&mut MultiReplacer { - vars: remap, + vars: &mut self.vars_for_inlining, changed: false, - clone: true, }); + body.visit_mut_with(&mut Remapper { vars: remap }); exprs.push(body.take()); tracing::debug!("inline: Inlining a call to an arrow function"); @@ -527,6 +526,10 @@ where self.changed = true; tracing::debug!("inline: Inlining a function call"); + if cfg!(feature = "debug") { + tracing::debug!("[Change]: {}", dump(&new, false)); + } + *e = new; } @@ -536,6 +539,10 @@ where } } + fn has_pending_inline_for(&self, id: &Id) -> bool { + self.lits.contains_key(id) || self.vars_for_inlining.contains_key(id) + } + fn can_inline_fn_like(&self, param_ids: &[Ident], body: &BlockStmt) -> bool { // Don't create top-level variables. if !param_ids.is_empty() && self.ctx.in_top_level() { @@ -566,7 +573,7 @@ where decls, .. })) => { - if decls.iter().any(|decl| match decl.name { + if decls.iter().any(|decl| match &decl.name { Pat::Ident(BindingIdent { id: Ident { @@ -575,7 +582,14 @@ where }, .. }) => true, - Pat::Ident(..) => false, + Pat::Ident(id) => { + if self.has_pending_inline_for(&id.to_id()) { + return true; + } + + false + } + _ => true, }) { return false; @@ -637,6 +651,45 @@ where let mut exprs = vec![]; + // We remap variables. + let mut remap = HashMap::default(); + let new_ctxt = SyntaxContext::empty().apply_mark(Mark::fresh(Mark::root())); + + let params = params + .iter() + .map(|i| { + // As the result of this function comes from `params` and `body`, we only need + // to remap those. + + let new = Ident::new(i.sym.clone(), i.span.with_ctxt(new_ctxt)); + remap.insert(i.to_id(), new_ctxt); + new + }) + .collect::>(); + + { + for stmt in &body.stmts { + if let Stmt::Decl(Decl::Var(var)) = stmt { + for decl in &var.decls { + let ids: Vec = find_ids(&decl.name); + + remap.extend(ids.into_iter().map(|id| { + ( + id, + SyntaxContext::empty().apply_mark(Mark::fresh(Mark::root())), + ) + })); + } + } + } + } + + body.visit_mut_with(&mut MultiReplacer { + vars: &mut self.vars_for_inlining, + changed: false, + }); + body.visit_mut_with(&mut Remapper { vars: remap }); + { let vars = params .iter() diff --git a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs index 9fe09c61e41..883f2558268 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs @@ -2202,9 +2202,8 @@ where self.with_ctx(ctx).handle_stmt_likes(stmts); stmts.visit_mut_with(&mut MultiReplacer { - vars: take(&mut self.vars_for_inlining), + vars: &mut self.vars_for_inlining, changed: false, - clone: false, }); drop_invalid_stmts(stmts); diff --git a/crates/swc_ecma_minifier/src/compress/optimize/unused.rs b/crates/swc_ecma_minifier/src/compress/optimize/unused.rs index 489c037e76b..adbd4fc9513 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/unused.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/unused.rs @@ -705,7 +705,7 @@ where .vars .get(&i.to_id()) .map(|v| (v.ref_count == 0 && v.usage_count == 0) || v.var_kind.is_some()) - .unwrap_or(true); + .unwrap_or(false); if can_remove_ident { self.changed = true; diff --git a/crates/swc_ecma_minifier/src/compress/optimize/util.rs b/crates/swc_ecma_minifier/src/compress/optimize/util.rs index d1df125e95d..e298cf3c448 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/util.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/util.rs @@ -2,7 +2,7 @@ use std::ops::{Deref, DerefMut}; use rustc_hash::FxHashMap; use swc_atoms::JsWord; -use swc_common::Span; +use swc_common::{Span, SyntaxContext}; use swc_ecma_ast::*; use swc_ecma_utils::{ident::IdentLike, prop_name_eq, ExprExt, Id}; use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith}; @@ -168,23 +168,36 @@ pub(crate) fn is_valid_for_lhs(e: &Expr) -> bool { !matches!(e, Expr::Lit(..) | Expr::Unary(..)) } -pub(crate) struct MultiReplacer { - pub vars: FxHashMap>, - pub changed: bool, - pub clone: bool, +/// Variable remapper +/// +/// - Used for evaluating IIFEs + +pub(crate) struct Remapper { + pub vars: FxHashMap, } -impl MultiReplacer { - fn var(&mut self, i: &Id) -> Option> { - if self.clone { - self.vars.get(i).cloned() - } else { - self.vars.remove(i) +impl VisitMut for Remapper { + noop_visit_mut_type!(); + + fn visit_mut_ident(&mut self, i: &mut Ident) { + if let Some(new_ctxt) = self.vars.get(&i.to_id()).copied() { + i.span.ctxt = new_ctxt; } } } -impl VisitMut for MultiReplacer { +pub(crate) struct MultiReplacer<'a> { + pub vars: &'a mut FxHashMap>, + pub changed: bool, +} + +impl MultiReplacer<'_> { + fn var(&mut self, i: &Id) -> Option> { + self.vars.remove(i) + } +} + +impl VisitMut for MultiReplacer<'_> { noop_visit_mut_type!(); fn visit_mut_expr(&mut self, e: &mut Expr) { diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/issues/2011/reduced/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/compress/fixture/issues/2011/reduced/analysis-snapshot.rust-debug index 4f90afc39c8..38bcc698bf8 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/issues/2011/reduced/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/compress/fixture/issues/2011/reduced/analysis-snapshot.rust-debug @@ -47,8 +47,8 @@ TestSnapshot { inline_prevented: false, ref_count: 1, cond_init: false, - declared: false, - declared_count: 0, + declared: true, + declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, assign_count: 0, @@ -62,7 +62,7 @@ TestSnapshot { accessed_props: {}, exported: false, used_above_decl: true, - is_fn_local: true, + is_fn_local: false, used_by_nested_fn: true, executed_multiple_time: false, used_in_cond: false, diff --git a/crates/swc_ecma_minifier/tests/terser/compress/collapse_vars/ignore_class/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/collapse_vars/ignore_class/analysis-snapshot.rust-debug index 6ea16aac06d..7d60b4031d2 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/collapse_vars/ignore_class/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/terser/compress/collapse_vars/ignore_class/analysis-snapshot.rust-debug @@ -116,6 +116,44 @@ TestSnapshot { infects: [], }, ), + ( + ( + Atom('dummy' type=inline), + #3, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 0, + cond_init: false, + declared: true, + declared_count: 1, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 0, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: false, + is_fn_local: true, + used_by_nested_fn: true, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: true, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), ( ( Atom('global' type=static), diff --git a/crates/swc_ecma_minifier/tests/terser/compress/drop-unused/issue_2418_1/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/drop-unused/issue_2418_1/analysis-snapshot.rust-debug index 11765461ef5..277b57c2a45 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/drop-unused/issue_2418_1/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/terser/compress/drop-unused/issue_2418_1/analysis-snapshot.rust-debug @@ -76,6 +76,44 @@ TestSnapshot { infects: [], }, ), + ( + ( + Atom('c' type=inline), + #2, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 0, + cond_init: false, + declared: true, + declared_count: 1, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 0, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: false, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: true, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), ( ( Atom('f' type=inline), diff --git a/crates/swc_ecma_minifier/tests/terser/compress/drop-unused/issue_2418_2/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/drop-unused/issue_2418_2/analysis-snapshot.rust-debug index 11765461ef5..277b57c2a45 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/drop-unused/issue_2418_2/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/terser/compress/drop-unused/issue_2418_2/analysis-snapshot.rust-debug @@ -76,6 +76,44 @@ TestSnapshot { infects: [], }, ), + ( + ( + Atom('c' type=inline), + #2, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 0, + cond_init: false, + declared: true, + declared_count: 1, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 0, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: false, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: true, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), ( ( Atom('f' type=inline), diff --git a/crates/swc_ecma_minifier/tests/terser/compress/drop-unused/issue_2418_3/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/drop-unused/issue_2418_3/analysis-snapshot.rust-debug index 11765461ef5..277b57c2a45 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/drop-unused/issue_2418_3/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/terser/compress/drop-unused/issue_2418_3/analysis-snapshot.rust-debug @@ -76,6 +76,44 @@ TestSnapshot { infects: [], }, ), + ( + ( + Atom('c' type=inline), + #2, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 0, + cond_init: false, + declared: true, + declared_count: 1, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 0, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: false, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: true, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), ( ( Atom('f' type=inline), diff --git a/crates/swc_ecma_minifier/tests/terser/compress/drop-unused/issue_2418_4/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/drop-unused/issue_2418_4/analysis-snapshot.rust-debug index 11765461ef5..277b57c2a45 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/drop-unused/issue_2418_4/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/terser/compress/drop-unused/issue_2418_4/analysis-snapshot.rust-debug @@ -76,6 +76,44 @@ TestSnapshot { infects: [], }, ), + ( + ( + Atom('c' type=inline), + #2, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 0, + cond_init: false, + declared: true, + declared_count: 1, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 0, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: false, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: true, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), ( ( Atom('f' type=inline), diff --git a/crates/swc_ecma_minifier/tests/terser/compress/drop-unused/issue_2418_5/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/drop-unused/issue_2418_5/analysis-snapshot.rust-debug index 11765461ef5..277b57c2a45 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/drop-unused/issue_2418_5/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/terser/compress/drop-unused/issue_2418_5/analysis-snapshot.rust-debug @@ -76,6 +76,44 @@ TestSnapshot { infects: [], }, ), + ( + ( + Atom('c' type=inline), + #2, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 0, + cond_init: false, + declared: true, + declared_count: 1, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 0, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: false, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: true, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), ( ( Atom('f' type=inline), diff --git a/crates/swc_ecma_minifier/tests/terser/compress/export/module_mangle_export_default_class/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/export/module_mangle_export_default_class/analysis-snapshot.rust-debug index 640d361a1a2..39daa007443 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/export/module_mangle_export_default_class/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/terser/compress/export/module_mangle_export_default_class/analysis-snapshot.rust-debug @@ -123,8 +123,8 @@ TestSnapshot { inline_prevented: true, ref_count: 1, cond_init: false, - declared: false, - declared_count: 0, + declared: true, + declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, assign_count: 0, @@ -138,12 +138,12 @@ TestSnapshot { accessed_props: {}, exported: false, used_above_decl: false, - is_fn_local: false, + is_fn_local: true, used_by_nested_fn: false, executed_multiple_time: false, used_in_cond: false, var_kind: None, - var_initialized: false, + var_initialized: true, declared_as_catch_param: false, no_side_effect_for_member_access: false, used_as_callee: false, diff --git a/crates/swc_ecma_minifier/tests/terser/compress/export/name_cache_mangle_export_default_class/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/export/name_cache_mangle_export_default_class/analysis-snapshot.rust-debug index 8a866ea0170..0610dd73ab9 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/export/name_cache_mangle_export_default_class/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/terser/compress/export/name_cache_mangle_export_default_class/analysis-snapshot.rust-debug @@ -123,8 +123,8 @@ TestSnapshot { inline_prevented: true, ref_count: 1, cond_init: false, - declared: false, - declared_count: 0, + declared: true, + declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, assign_count: 0, @@ -138,12 +138,12 @@ TestSnapshot { accessed_props: {}, exported: false, used_above_decl: false, - is_fn_local: false, + is_fn_local: true, used_by_nested_fn: false, executed_multiple_time: false, used_in_cond: false, var_kind: None, - var_initialized: false, + var_initialized: true, declared_as_catch_param: false, no_side_effect_for_member_access: false, used_as_callee: false, diff --git a/crates/swc_ecma_minifier/tests/terser/compress/harmony/class_expression_statement/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/harmony/class_expression_statement/analysis-snapshot.rust-debug index 573b79475cb..f20cb056672 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/harmony/class_expression_statement/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/terser/compress/harmony/class_expression_statement/analysis-snapshot.rust-debug @@ -9,8 +9,8 @@ TestSnapshot { inline_prevented: false, ref_count: 0, cond_init: false, - declared: false, - declared_count: 0, + declared: true, + declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, assign_count: 0, @@ -24,12 +24,12 @@ TestSnapshot { accessed_props: {}, exported: false, used_above_decl: false, - is_fn_local: false, + is_fn_local: true, used_by_nested_fn: false, executed_multiple_time: false, used_in_cond: false, var_kind: None, - var_initialized: false, + var_initialized: true, declared_as_catch_param: false, no_side_effect_for_member_access: false, used_as_callee: false, @@ -76,6 +76,44 @@ TestSnapshot { infects: [], }, ), + ( + ( + Atom('NamedClassExpr' type=dynamic), + #2, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 0, + cond_init: false, + declared: true, + declared_count: 1, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 0, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: false, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: true, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), ( ( Atom('expr' type=inline), diff --git a/crates/swc_ecma_minifier/tests/terser/compress/harmony/class_expression_statement_unused/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/harmony/class_expression_statement_unused/analysis-snapshot.rust-debug index 573b79475cb..f20cb056672 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/harmony/class_expression_statement_unused/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/terser/compress/harmony/class_expression_statement_unused/analysis-snapshot.rust-debug @@ -9,8 +9,8 @@ TestSnapshot { inline_prevented: false, ref_count: 0, cond_init: false, - declared: false, - declared_count: 0, + declared: true, + declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, assign_count: 0, @@ -24,12 +24,12 @@ TestSnapshot { accessed_props: {}, exported: false, used_above_decl: false, - is_fn_local: false, + is_fn_local: true, used_by_nested_fn: false, executed_multiple_time: false, used_in_cond: false, var_kind: None, - var_initialized: false, + var_initialized: true, declared_as_catch_param: false, no_side_effect_for_member_access: false, used_as_callee: false, @@ -76,6 +76,44 @@ TestSnapshot { infects: [], }, ), + ( + ( + Atom('NamedClassExpr' type=dynamic), + #2, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 0, + cond_init: false, + declared: true, + declared_count: 1, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 0, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: false, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: true, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), ( ( Atom('expr' type=inline), diff --git a/crates/swc_ecma_minifier/tests/terser/compress/harmony/class_expression_statement_unused_toplevel/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/harmony/class_expression_statement_unused_toplevel/analysis-snapshot.rust-debug index 573b79475cb..f20cb056672 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/harmony/class_expression_statement_unused_toplevel/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/terser/compress/harmony/class_expression_statement_unused_toplevel/analysis-snapshot.rust-debug @@ -9,8 +9,8 @@ TestSnapshot { inline_prevented: false, ref_count: 0, cond_init: false, - declared: false, - declared_count: 0, + declared: true, + declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, assign_count: 0, @@ -24,12 +24,12 @@ TestSnapshot { accessed_props: {}, exported: false, used_above_decl: false, - is_fn_local: false, + is_fn_local: true, used_by_nested_fn: false, executed_multiple_time: false, used_in_cond: false, var_kind: None, - var_initialized: false, + var_initialized: true, declared_as_catch_param: false, no_side_effect_for_member_access: false, used_as_callee: false, @@ -76,6 +76,44 @@ TestSnapshot { infects: [], }, ), + ( + ( + Atom('NamedClassExpr' type=dynamic), + #2, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 0, + cond_init: false, + declared: true, + declared_count: 1, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 0, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: false, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: true, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), ( ( Atom('expr' type=inline), diff --git a/crates/swc_ecma_minifier/tests/terser/compress/harmony/class_extends_class/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/harmony/class_extends_class/analysis-snapshot.rust-debug index d863b29aa42..6585618bf59 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/harmony/class_extends_class/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/terser/compress/harmony/class_extends_class/analysis-snapshot.rust-debug @@ -38,6 +38,44 @@ TestSnapshot { infects: [], }, ), + ( + ( + Atom('base' type=inline), + #2, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 0, + cond_init: false, + declared: true, + declared_count: 1, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 0, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: false, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: true, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), ( ( Atom('named' type=inline), diff --git a/crates/swc_ecma_minifier/tests/terser/compress/harmony/class_name_can_be_mangled/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/harmony/class_name_can_be_mangled/analysis-snapshot.rust-debug index 6d45f66c30b..3b6de941149 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/harmony/class_name_can_be_mangled/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/terser/compress/harmony/class_name_can_be_mangled/analysis-snapshot.rust-debug @@ -9,8 +9,8 @@ TestSnapshot { inline_prevented: false, ref_count: 0, cond_init: false, - declared: false, - declared_count: 0, + declared: true, + declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, assign_count: 0, @@ -24,12 +24,12 @@ TestSnapshot { accessed_props: {}, exported: false, used_above_decl: false, - is_fn_local: false, + is_fn_local: true, used_by_nested_fn: true, executed_multiple_time: false, used_in_cond: false, var_kind: None, - var_initialized: false, + var_initialized: true, declared_as_catch_param: false, no_side_effect_for_member_access: false, used_as_callee: false, diff --git a/crates/swc_ecma_minifier/tests/terser/compress/harmony/class_name_can_be_preserved/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/harmony/class_name_can_be_preserved/analysis-snapshot.rust-debug index 176b468198f..87f1e390c7c 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/harmony/class_name_can_be_preserved/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/terser/compress/harmony/class_name_can_be_preserved/analysis-snapshot.rust-debug @@ -1,5 +1,43 @@ TestSnapshot { vars: [ + ( + ( + Atom('Baz' type=inline), + #3, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 0, + cond_init: false, + declared: true, + declared_count: 1, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 0, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: false, + is_fn_local: true, + used_by_nested_fn: true, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: true, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), ( ( Atom('Foo' type=inline), diff --git a/crates/swc_ecma_minifier/tests/terser/compress/harmony/class_name_can_be_preserved_with_reserved/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/harmony/class_name_can_be_preserved_with_reserved/analysis-snapshot.rust-debug index d4546f88caf..95101ea6728 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/harmony/class_name_can_be_preserved_with_reserved/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/terser/compress/harmony/class_name_can_be_preserved_with_reserved/analysis-snapshot.rust-debug @@ -87,8 +87,8 @@ TestSnapshot { inline_prevented: false, ref_count: 0, cond_init: false, - declared: false, - declared_count: 0, + declared: true, + declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, assign_count: 0, @@ -102,12 +102,12 @@ TestSnapshot { accessed_props: {}, exported: false, used_above_decl: false, - is_fn_local: false, + is_fn_local: true, used_by_nested_fn: true, executed_multiple_time: false, used_in_cond: false, var_kind: None, - var_initialized: false, + var_initialized: true, declared_as_catch_param: false, no_side_effect_for_member_access: false, used_as_callee: false, @@ -203,8 +203,8 @@ TestSnapshot { inline_prevented: false, ref_count: 0, cond_init: false, - declared: false, - declared_count: 0, + declared: true, + declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, assign_count: 0, @@ -218,12 +218,12 @@ TestSnapshot { accessed_props: {}, exported: false, used_above_decl: false, - is_fn_local: false, + is_fn_local: true, used_by_nested_fn: true, executed_multiple_time: false, used_in_cond: false, var_kind: None, - var_initialized: false, + var_initialized: true, declared_as_catch_param: false, no_side_effect_for_member_access: false, used_as_callee: false, diff --git a/crates/swc_ecma_minifier/tests/terser/compress/harmony/classes/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/harmony/classes/analysis-snapshot.rust-debug index 3bad61050c9..37a16c81123 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/harmony/classes/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/terser/compress/harmony/classes/analysis-snapshot.rust-debug @@ -9,8 +9,8 @@ TestSnapshot { inline_prevented: false, ref_count: 0, cond_init: false, - declared: false, - declared_count: 0, + declared: true, + declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, assign_count: 0, @@ -24,12 +24,12 @@ TestSnapshot { accessed_props: {}, exported: false, used_above_decl: false, - is_fn_local: false, + is_fn_local: true, used_by_nested_fn: false, executed_multiple_time: false, used_in_cond: false, var_kind: None, - var_initialized: false, + var_initialized: true, declared_as_catch_param: false, no_side_effect_for_member_access: false, used_as_callee: false, diff --git a/crates/swc_ecma_minifier/tests/terser/compress/harmony/export_default_class_decl/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/harmony/export_default_class_decl/analysis-snapshot.rust-debug index 1f3cdd89fa3..2c75e956730 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/harmony/export_default_class_decl/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/terser/compress/harmony/export_default_class_decl/analysis-snapshot.rust-debug @@ -47,8 +47,8 @@ TestSnapshot { inline_prevented: true, ref_count: 0, cond_init: false, - declared: false, - declared_count: 0, + declared: true, + declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, assign_count: 0, @@ -62,12 +62,12 @@ TestSnapshot { accessed_props: {}, exported: false, used_above_decl: false, - is_fn_local: false, + is_fn_local: true, used_by_nested_fn: false, executed_multiple_time: false, used_in_cond: false, var_kind: None, - var_initialized: false, + var_initialized: true, declared_as_catch_param: false, no_side_effect_for_member_access: false, used_as_callee: false, diff --git a/crates/swc_ecma_minifier/tests/terser/compress/hoist_props/hoist_class/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/hoist_props/hoist_class/analysis-snapshot.rust-debug index 6c495cce2c4..841f9f11376 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/hoist_props/hoist_class/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/terser/compress/hoist_props/hoist_class/analysis-snapshot.rust-debug @@ -9,8 +9,8 @@ TestSnapshot { inline_prevented: false, ref_count: 0, cond_init: false, - declared: false, - declared_count: 0, + declared: true, + declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, assign_count: 0, @@ -24,12 +24,12 @@ TestSnapshot { accessed_props: {}, exported: false, used_above_decl: false, - is_fn_local: false, + is_fn_local: true, used_by_nested_fn: false, executed_multiple_time: false, used_in_cond: false, var_kind: None, - var_initialized: false, + var_initialized: true, declared_as_catch_param: false, no_side_effect_for_member_access: false, used_as_callee: false, diff --git a/crates/swc_ecma_minifier/tests/terser/compress/hoist_props/hoist_class_with_new/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/hoist_props/hoist_class_with_new/analysis-snapshot.rust-debug index 35cc637d9ed..985dcfdcc74 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/hoist_props/hoist_class_with_new/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/terser/compress/hoist_props/hoist_class_with_new/analysis-snapshot.rust-debug @@ -9,8 +9,8 @@ TestSnapshot { inline_prevented: false, ref_count: 0, cond_init: false, - declared: false, - declared_count: 0, + declared: true, + declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, assign_count: 0, @@ -24,12 +24,12 @@ TestSnapshot { accessed_props: {}, exported: false, used_above_decl: false, - is_fn_local: false, + is_fn_local: true, used_by_nested_fn: false, executed_multiple_time: false, used_in_cond: false, var_kind: None, - var_initialized: false, + var_initialized: true, declared_as_catch_param: false, no_side_effect_for_member_access: false, used_as_callee: false, diff --git a/crates/swc_ecma_minifier/tests/terser/compress/issue-2001/export_default_class_1/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/issue-2001/export_default_class_1/analysis-snapshot.rust-debug index 8045223a58b..2416214a84a 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/issue-2001/export_default_class_1/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/terser/compress/issue-2001/export_default_class_1/analysis-snapshot.rust-debug @@ -9,8 +9,8 @@ TestSnapshot { inline_prevented: true, ref_count: 0, cond_init: false, - declared: false, - declared_count: 0, + declared: true, + declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, assign_count: 0, @@ -24,12 +24,12 @@ TestSnapshot { accessed_props: {}, exported: false, used_above_decl: false, - is_fn_local: false, + is_fn_local: true, used_by_nested_fn: false, executed_multiple_time: false, used_in_cond: false, var_kind: None, - var_initialized: false, + var_initialized: true, declared_as_catch_param: false, no_side_effect_for_member_access: false, used_as_callee: false, diff --git a/crates/swc_ecma_minifier/tests/terser/compress/issue-2001/export_default_class_2/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/issue-2001/export_default_class_2/analysis-snapshot.rust-debug index 8045223a58b..2416214a84a 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/issue-2001/export_default_class_2/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/terser/compress/issue-2001/export_default_class_2/analysis-snapshot.rust-debug @@ -9,8 +9,8 @@ TestSnapshot { inline_prevented: true, ref_count: 0, cond_init: false, - declared: false, - declared_count: 0, + declared: true, + declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, assign_count: 0, @@ -24,12 +24,12 @@ TestSnapshot { accessed_props: {}, exported: false, used_above_decl: false, - is_fn_local: false, + is_fn_local: true, used_by_nested_fn: false, executed_multiple_time: false, used_in_cond: false, var_kind: None, - var_initialized: false, + var_initialized: true, declared_as_catch_param: false, no_side_effect_for_member_access: false, used_as_callee: false, diff --git a/crates/swc_ecma_minifier/tests/terser/compress/issue-2001/export_default_class_3/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/issue-2001/export_default_class_3/analysis-snapshot.rust-debug index 8045223a58b..2416214a84a 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/issue-2001/export_default_class_3/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/terser/compress/issue-2001/export_default_class_3/analysis-snapshot.rust-debug @@ -9,8 +9,8 @@ TestSnapshot { inline_prevented: true, ref_count: 0, cond_init: false, - declared: false, - declared_count: 0, + declared: true, + declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, assign_count: 0, @@ -24,12 +24,12 @@ TestSnapshot { accessed_props: {}, exported: false, used_above_decl: false, - is_fn_local: false, + is_fn_local: true, used_by_nested_fn: false, executed_multiple_time: false, used_in_cond: false, var_kind: None, - var_initialized: false, + var_initialized: true, declared_as_catch_param: false, no_side_effect_for_member_access: false, used_as_callee: false, diff --git a/crates/swc_ecma_minifier/tests/terser/compress/issue-2001/export_mangle_4/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/issue-2001/export_mangle_4/analysis-snapshot.rust-debug index 1220c8803ff..2fa97f0117d 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/issue-2001/export_mangle_4/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/terser/compress/issue-2001/export_mangle_4/analysis-snapshot.rust-debug @@ -9,8 +9,8 @@ TestSnapshot { inline_prevented: true, ref_count: 0, cond_init: false, - declared: false, - declared_count: 0, + declared: true, + declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, assign_count: 0, @@ -24,12 +24,12 @@ TestSnapshot { accessed_props: {}, exported: false, used_above_decl: false, - is_fn_local: false, + is_fn_local: true, used_by_nested_fn: false, executed_multiple_time: false, used_in_cond: false, var_kind: None, - var_initialized: false, + var_initialized: true, declared_as_catch_param: false, no_side_effect_for_member_access: false, used_as_callee: false, diff --git a/crates/swc_ecma_minifier/tests/terser/compress/issue-2001/export_toplevel_2/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/issue-2001/export_toplevel_2/analysis-snapshot.rust-debug index 74c6fc6476d..b5f94afd855 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/issue-2001/export_toplevel_2/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/terser/compress/issue-2001/export_toplevel_2/analysis-snapshot.rust-debug @@ -85,8 +85,8 @@ TestSnapshot { inline_prevented: true, ref_count: 0, cond_init: false, - declared: false, - declared_count: 0, + declared: true, + declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, assign_count: 0, @@ -100,12 +100,12 @@ TestSnapshot { accessed_props: {}, exported: false, used_above_decl: false, - is_fn_local: false, + is_fn_local: true, used_by_nested_fn: false, executed_multiple_time: false, used_in_cond: false, var_kind: None, - var_initialized: false, + var_initialized: true, declared_as_catch_param: false, no_side_effect_for_member_access: false, used_as_callee: false,