diff --git a/Cargo.lock b/Cargo.lock index ab0a125e7829..bb283277a194 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2822,7 +2822,7 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_compat" -version = "0.45.1" +version = "0.45.2" dependencies = [ "ahash", "arrayvec", diff --git a/ecmascript/transforms/compat/Cargo.toml b/ecmascript/transforms/compat/Cargo.toml index 6a6056b6a83b..452b0342557f 100644 --- a/ecmascript/transforms/compat/Cargo.toml +++ b/ecmascript/transforms/compat/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_transforms_compat" repository = "https://github.com/swc-project/swc.git" -version = "0.45.1" +version = "0.45.2" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] diff --git a/ecmascript/transforms/compat/src/es2015/destructuring.rs b/ecmascript/transforms/compat/src/es2015/destructuring.rs index 2b550b202b91..994540ff2f36 100644 --- a/ecmascript/transforms/compat/src/es2015/destructuring.rs +++ b/ecmascript/transforms/compat/src/es2015/destructuring.rs @@ -322,6 +322,21 @@ impl AssignFolder { "destructuring pattern binding requires initializer" ); + if props.len() == 1 { + match &props[0] { + ObjectPatProp::Assign(p @ AssignPatProp { value: None, .. }) => { + decls.push(VarDeclarator { + span: decl.span, + name: Pat::Ident(p.key.clone().into()), + init: Some(Box::new(decl.init.unwrap().make_member(p.key.clone()))), + definite: false, + }); + return; + } + _ => {} + } + } + let can_be_null = can_be_null(decl.init.as_ref().unwrap()); let ref_ident = make_ref_ident(self.c, decls, decl.init); @@ -713,6 +728,22 @@ impl Fold for AssignFolder { }) } Pat::Object(ObjectPat { span, props, .. }) => { + if props.len() == 1 { + match &props[0] { + ObjectPatProp::Assign(p @ AssignPatProp { value: None, .. }) => { + return Expr::Assign(AssignExpr { + span, + op: op!("="), + left: PatOrExpr::Pat(Box::new(Pat::Ident( + p.key.clone().into(), + ))), + right: Box::new(right.make_member(p.key.clone())), + }); + } + _ => {} + } + } + let ref_ident = make_ref_ident(self.c, &mut self.vars, None); let mut exprs = vec![]; diff --git a/ecmascript/transforms/compat/tests/es2015_destructuring.rs b/ecmascript/transforms/compat/tests/es2015_destructuring.rs index cdb2d690bac7..48e94fd09dba 100644 --- a/ecmascript/transforms/compat/tests/es2015_destructuring.rs +++ b/ecmascript/transforms/compat/tests/es2015_destructuring.rs @@ -186,7 +186,7 @@ test!( var { x: { y } = {} } = z;"#, r#"var z = { }; -var tmp = z.x, ref = tmp === void 0 ? {} : tmp, y = ref.y;"# +var tmp = z.x, y = (tmp === void 0 ? {} : tmp).y;"# ); test!( @@ -527,7 +527,7 @@ const bar = { qux: 'baz' } }; -const _Foo = bar[Foo], qux = _Foo.qux;" +const qux = bar[Foo].qux;" ); test!( @@ -1225,7 +1225,7 @@ var { x: { y } = {} } = z; "#, r#" var z = {}; -var tmp = z.x, ref = tmp === void 0 ? {} : tmp, y = ref.y; +var tmp = z.x, y = (tmp === void 0 ? {} : tmp).y; "# ); @@ -1607,3 +1607,27 @@ test!( ref = b, ref1 = ref[0], a = ref1 === void 0 ? 1 : ref1, ref; " ); + +test!( + syntax(), + |_| tr(), + next_001, + " + const { NODE_ENV }= process.env; + ", + " + const NODE_ENV = process.env.NODE_ENV; + " +); + +test!( + syntax(), + |_| tr(), + next_002, + " + ({ NODE_ENV }= process.env); + ", + " + NODE_ENV = process.env.NODE_ENV; + " +); diff --git a/ecmascript/transforms/module/tests/common_js.rs b/ecmascript/transforms/module/tests/common_js.rs index c45fb73723c1..3c831d68801e 100644 --- a/ecmascript/transforms/module/tests/common_js.rs +++ b/ecmascript/transforms/module/tests/common_js.rs @@ -4282,7 +4282,7 @@ let SomeClass = function() { _createClass(SomeClass, [{ key: 'call', value: function call() { - var _props = this.props, myFunction = _props.myFunction; + var myFunction = this.props.myFunction; if (myFunction) { myFunction(); } else { diff --git a/tests/fixture/issue-2232/case1/output/index.js b/tests/fixture/issue-2232/case1/output/index.js index 2c6d3d57ab54..ec34851de742 100644 --- a/tests/fixture/issue-2232/case1/output/index.js +++ b/tests/fixture/issue-2232/case1/output/index.js @@ -92,11 +92,11 @@ var Foo = /*#__PURE__*/ function() { var ref; while(1)switch(_ctx.prev = _ctx.next){ case 0: - var ref1, ref2; + var ref1; ref1 = _param, ref = ref1.input, toNumber = ref.toNumber, messageBody = ref.messageBody, ref, ref1, all = _objectWithoutProperties(_param.input, [ "toNumber", "messageBody" - ]), ref2 = _param1, dataSources = ref2.dataSources, ref2; + ]), dataSources = _param1.dataSources; case 1: case "end": return _ctx.stop(); diff --git a/tests/fixture/issue-2232/case2/output/index.ts b/tests/fixture/issue-2232/case2/output/index.ts index 16dc72f2f574..81d143a2d246 100644 --- a/tests/fixture/issue-2232/case2/output/index.ts +++ b/tests/fixture/issue-2232/case2/output/index.ts @@ -66,11 +66,11 @@ var resolver = { var ref; while(1)switch(_ctx.prev = _ctx.next){ case 0: - var ref1, ref2; + var ref1; ref1 = _param, ref = ref1.input, toNumber = ref.toNumber, messageBody = ref.messageBody, ref, ref1, all = _objectWithoutProperties(_param.input, [ "toNumber", "messageBody" - ]), ref2 = _param1, dataSources = ref2.dataSources, ref2; + ]), dataSources = _param1.dataSources; case 1: case "end": return _ctx.stop(); diff --git a/tests/tsc-references/async/es6/asyncWithVarShadowing_es6/input.ts/es5.1.normal/output.js b/tests/tsc-references/async/es6/asyncWithVarShadowing_es6/input.ts/es5.1.normal/output.js index 9c400c0d3849..f0c870d8de60 100644 --- a/tests/tsc-references/async/es6/asyncWithVarShadowing_es6/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/async/es6/asyncWithVarShadowing_es6/input.ts/es5.1.normal/output.js @@ -151,8 +151,7 @@ function _fn5() { return regeneratorRuntime.wrap(function _callee$(_ctx) { while(1)switch(_ctx.prev = _ctx.next){ case 0: - var ref; - ref = y, x = ref.x, ref; + x = y.x; case 1: case "end": return _ctx.stop(); @@ -225,11 +224,10 @@ function _fn9() { _fn9 = _asyncToGenerator(regeneratorRuntime.mark(function _callee(x) { var x; return regeneratorRuntime.wrap(function _callee$(_ctx) { - var ref; while(1)switch(_ctx.prev = _ctx.next){ case 0: - var ref2; - ref2 = y, ref = ref2.z, x = ref.x, ref, ref2; + var ref; + ref = y, x = ref.z.x, ref; case 1: case "end": return _ctx.stop(); @@ -248,9 +246,8 @@ function _fn10() { var ref; while(1)switch(_ctx.prev = _ctx.next){ case 0: - var ref3; - var ref4; - ref3 = y, ref = y, ref4 = ref, x = ref4.x, ref4, ref3; + var ref2; + ref2 = y, ref = y, x = ref.x, ref2; case 1: case "end": return _ctx.stop(); @@ -306,8 +303,8 @@ function _fn13() { return regeneratorRuntime.wrap(function _callee$(_ctx) { while(1)switch(_ctx.prev = _ctx.next){ case 0: - var ref, ref5; - ref = y, ref5 = ref[0], x = ref5 === void 0 ? y : ref5, ref; + var ref, ref3; + ref = y, ref3 = ref[0], x = ref3 === void 0 ? y : ref3, ref; case 1: case "end": return _ctx.stop(); @@ -363,8 +360,8 @@ function _fn16() { return regeneratorRuntime.wrap(function _callee$(_ctx) { while(1)switch(_ctx.prev = _ctx.next){ case 0: - var ref, ref6; - ref = y, ref6 = ref[0], x = ref6[0], ref6, ref; + var ref, ref4; + ref = y, ref4 = ref[0], x = ref4[0], ref4, ref; case 1: case "end": return _ctx.stop(); @@ -382,8 +379,8 @@ function _fn17() { return regeneratorRuntime.wrap(function _callee$(_ctx) { while(1)switch(_ctx.prev = _ctx.next){ case 0: - var ref, ref7, ref8; - ref = y, ref7 = ref[0], ref8 = ref7 === void 0 ? y : ref7, x = ref8[0], ref8, ref; + var ref, ref5, ref6; + ref = y, ref5 = ref[0], ref6 = ref5 === void 0 ? y : ref5, x = ref6[0], ref6, ref; case 1: case "end": return _ctx.stop(); @@ -665,8 +662,7 @@ function _fn31() { return regeneratorRuntime.wrap(function _callee$(_ctx) { while(1)switch(_ctx.prev = _ctx.next){ case 0: - var ref; - for(ref = y, x = ref.x, ref;;){ + for(x = y.x;;){ } case 1: case "end": @@ -806,8 +802,7 @@ function _fn36() { _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; _ctx.prev = 1; for(_iterator = y[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ - var ref; - ref = _step.value, x = ref.x, ref; + x = _step.value.x; } _ctx.next = 9; break; diff --git a/tests/tsc-references/es6/arrowFunction/emitArrowFunctionES6/input.ts/es5.1.normal/output.js b/tests/tsc-references/es6/arrowFunction/emitArrowFunctionES6/input.ts/es5.1.normal/output.js index ef7040817100..c467fc3d3d7f 100644 --- a/tests/tsc-references/es6/arrowFunction/emitArrowFunctionES6/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/es6/arrowFunction/emitArrowFunctionES6/input.ts/es5.1.normal/output.js @@ -76,7 +76,7 @@ var p6 = function(param) { var a = param.a; }; var p7 = function(param) { - var _a = param.a, b = _a.b; + var b = param.a.b; }; var p8 = function(param) { var _a = param.a, a = _a === void 0 ? 1 : _a; diff --git a/tests/tsc-references/es6/destructuring/declarationsAndAssignments/input.ts/es5.1.normal/output.js b/tests/tsc-references/es6/destructuring/declarationsAndAssignments/input.ts/es5.1.normal/output.js index a7df9929f5e6..78644dd80a3b 100644 --- a/tests/tsc-references/es6/destructuring/declarationsAndAssignments/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/es6/destructuring/declarationsAndAssignments/input.ts/es5.1.normal/output.js @@ -73,32 +73,32 @@ function f2() { x: 5, y: "hello" }, ref = ref !== null ? ref : _throw(new TypeError("Cannot destructure undefined")); // Error, no x and y in target - var ref5 = { + var x = { x: 5, y: "hello" - }, x = ref5.x; // Error, no y in target - var ref6 = { + }.x; // Error, no y in target + var y = { x: 5, y: "hello" - }, y = ref6.y; // Error, no x in target - var ref7 = { + }.y; // Error, no x in target + var ref5 = { x: 5, y: "hello" - }, x = ref7.x, y = ref7.y; + }, x = ref5.x, y = ref5.y; var x; var y; - var ref8 = { + var ref6 = { x: 5, y: "hello" - }, a = ref8.x; // Error, no y in target - var ref9 = { + }, a = ref6.x; // Error, no y in target + var ref7 = { x: 5, y: "hello" - }, b = ref9.y; // Error, no x in target - var ref10 = { + }, b = ref7.y; // Error, no x in target + var ref8 = { x: 5, y: "hello" - }, a = ref10.x, b = ref10.y; + }, a = ref8.x, b = ref8.y; var a; var b; } @@ -134,41 +134,41 @@ function f7() { } function f8() { var ref = [], a = ref[0], b = ref[1], c = ref[2]; // Error, [] is an empty tuple - var ref12 = [ + var ref10 = [ 1 - ], d = ref12[0], e = ref12[1], f = ref12[2]; // Error, [1] is a tuple + ], d = ref10[0], e = ref10[1], f = ref10[2]; // Error, [1] is a tuple } function f9() { var ref = _slicedToArray({ }, 2), a = ref[0], b = ref[1]; // Error, not array type - var ref13 = _slicedToArray({ + var ref11 = _slicedToArray({ 0: 10, 1: 20 - }, 2), c = ref13[0], d = ref13[1]; // Error, not array type + }, 2), c = ref11[0], d = ref11[1]; // Error, not array type var e = 10, f = 20; } function f10() { var ref = { }, a = ref.a, b = ref.b; // Error - var ref14 = [], a = ref14.a, b = ref14.b; // Error + var ref12 = [], a = ref12.a, b = ref12.b; // Error } function f11() { var ref = { x: 10, y: "hello" }, a = ref.x, b = ref.y; - var ref15 = { + var ref13 = { 0: 10, 1: "hello" - }, a = ref15[0], b = ref15[1]; - var ref16 = { + }, a = ref13[0], b = ref13[1]; + var ref14 = { "<": 10, ">": "hello" - }, a = ref16["<"], b = ref16[">"]; - var ref17 = [ + }, a = ref14["<"], b = ref14[">"]; + var ref15 = [ 10, "hello" - ], a = ref17[0], b = ref17[1]; + ], a = ref15[0], b = ref15[1]; var a; var b; } @@ -185,7 +185,7 @@ function f12() { x: 10, y: false } - ] : tmp, 2), b = ref[0], ref18 = ref[1], x = ref18.x, c = ref18.y; + ] : tmp, 2), b = ref[0], ref16 = ref[1], x = ref16.x, c = ref16.y; var a; var b; var x; @@ -205,7 +205,7 @@ function f13() { ], a = ref[0], b = ref[1]; } function f14(param) { - var _param = _slicedToArray(param, 2), tmp = _param[0], a = tmp === void 0 ? 1 : tmp, ref = _slicedToArray(_param[1], 2), tmp3 = ref[0], b = tmp3 === void 0 ? "hello" : tmp3, ref19 = ref[1], x = ref19.x, tmp4 = ref19.y, c = tmp4 === void 0 ? false : tmp4; + var _param = _slicedToArray(param, 2), tmp = _param[0], a = tmp === void 0 ? 1 : tmp, ref = _slicedToArray(_param[1], 2), tmp3 = ref[0], b = tmp3 === void 0 ? "hello" : tmp3, ref17 = ref[1], x = ref17.x, tmp4 = ref17.y, c = tmp4 === void 0 ? false : tmp4; var a; var b; var c; @@ -268,7 +268,7 @@ f17({ c: true }); f17(f15()); -var ref11, ref1; +var ref9, ref1; function f18() { var a; var b; @@ -278,22 +278,22 @@ function f18() { a: a, b: b }, a = ref.a, b = ref.b, ref; - var ref20; - ref20 = { + var ref18; + ref18 = { b: b, a: a - }, a = ref20.a, b = ref20.b, ref20; - var ref21; - ref21 = [ + }, a = ref18.a, b = ref18.b, ref18; + var ref19; + ref19 = [ a, b - ], aa[0] = ref21[0], b = ref21[1], ref21; - var ref22; - ref22 = [ + ], aa[0] = ref19[0], b = ref19[1], ref19; + var ref20; + ref20 = [ b, a - ], a = ref22[0], b = ref22[1], ref22; // Error - ref11 = 1, a = ref11, ref1 = "abc", b = ref1; + ], a = ref20[0], b = ref20[1], ref20; // Error + ref9 = 1, a = ref9, ref1 = "abc", b = ref1; } var ref2; function f19() { @@ -304,20 +304,20 @@ function f19() { b, a ], a = ref[0], b = ref[1], ref; - var ref23; - ref23 = { + var ref21; + ref21 = { b: b, a: a - }, a = ref23.a, b = ref23.b, ref23; + }, a = ref21.a, b = ref21.b, ref21; ref2 = [ 1, 2 ], [a, b] = ref2; - var ref24; - var x = (ref24 = [ + var ref22; + var x = (ref22 = [ 1, 2 - ], a = ref24[0], b = ref24[1], ref24); + ], a = ref22[0], b = ref22[1], ref22); } function f20(v) { var x; @@ -333,12 +333,12 @@ function f20(v) { var _v3 = _toArray(v), x = _v3[0], y = _v3[1], z = _v3[2], a0 = _v3.slice(3); var ref; ref = v, a3 = ref.slice(0), ref; + var ref23; + ref23 = v, x = ref23[0], a2 = ref23.slice(1), ref23; + var ref24; + ref24 = v, x = ref24[0], y = ref24[1], a1 = ref24.slice(2), ref24; var ref25; - ref25 = v, x = ref25[0], a2 = ref25.slice(1), ref25; - var ref26; - ref26 = v, x = ref26[0], y = ref26[1], a1 = ref26.slice(2), ref26; - var ref27; - ref27 = v, x = ref27[0], y = ref27[1], z = ref27[2], a0 = ref27.slice(3), ref27; + ref25 = v, x = ref25[0], y = ref25[1], z = ref25[2], a0 = ref25.slice(3), ref25; } function f21(v) { var x; @@ -354,10 +354,10 @@ function f21(v) { var _v6 = _toArray(v), x = _v6[0], y = _v6[1], z = _v6[2], a3 = _v6.slice(3); var ref; ref = v, a0 = ref.slice(0), ref; + var ref26; + ref26 = v, x = ref26[0], a1 = ref26.slice(1), ref26; + var ref27; + ref27 = v, x = ref27[0], y = ref27[1], a2 = ref27.slice(2), ref27; var ref28; - ref28 = v, x = ref28[0], a1 = ref28.slice(1), ref28; - var ref29; - ref29 = v, x = ref29[0], y = ref29[1], a2 = ref29.slice(2), ref29; - var ref30; - ref30 = v, x = ref30[0], y = ref30[1], z = ref30[2], a3 = ref30.slice(3), ref30; + ref28 = v, x = ref28[0], y = ref28[1], z = ref28[2], a3 = ref28.slice(3), ref28; } diff --git a/tests/tsc-references/es6/destructuring/destructuringControlFlow/input.ts/es5.1.normal/output.js b/tests/tsc-references/es6/destructuring/destructuringControlFlow/input.ts/es5.1.normal/output.js index cc073e9ff9eb..aa5adbf65767 100644 --- a/tests/tsc-references/es6/destructuring/destructuringControlFlow/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/es6/destructuring/destructuringControlFlow/input.ts/es5.1.normal/output.js @@ -61,12 +61,11 @@ function f3(obj) { } function f4() { var x; + x = 0..x; // Error var ref; - ref = 0, x = ref.x, ref; // Error + ref = 0, x = ref["x"], ref; // Error var ref3; - ref3 = 0, x = ref3["x"], ref3; // Error - var ref4; - ref4 = 0, x = ref4["x" + ""], ref4; // Errpr + ref3 = 0, x = ref3["x" + ""], ref3; // Errpr } var ref2 = [ "foo" diff --git a/tests/tsc-references/es6/destructuring/destructuringObjectBindingPatternAndAssignment1ES5/input.ts/es5.1.normal/output.js b/tests/tsc-references/es6/destructuring/destructuringObjectBindingPatternAndAssignment1ES5/input.ts/es5.1.normal/output.js index bb6bc2f8c278..32cb6cc7fb3f 100644 --- a/tests/tsc-references/es6/destructuring/destructuringObjectBindingPatternAndAssignment1ES5/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/es6/destructuring/destructuringObjectBindingPatternAndAssignment1ES5/input.ts/es5.1.normal/output.js @@ -3,32 +3,32 @@ // V is an object assignment pattern and, for each assignment property P in V, // S is the type Any, or var a1 = undefined.a1; -var ref = { -}, a2 = ref.a2; +var a2 = { +}.a2; // V is an object assignment pattern and, for each assignment property P in V, // S has an apparent property with the property name specified in // P of a type that is assignable to the target given in P, or -var ref1 = { +var b1 = { b1: 1 -}, b1 = ref1.b1; -var ref2 = { +}.b1; +var ref = { b2: { b21: "world" } -}, tmp = ref2.b2, ref3 = tmp === void 0 ? { +}, tmp = ref.b2, b21 = (tmp === void 0 ? { b21: "string" -} : tmp, b21 = ref3.b21; -var ref4 = { +} : tmp).b21; +var ref1 = { 1: "string" -}, b3 = ref4[1]; -var ref5 = { +}, b3 = ref1[1]; +var ref2 = { b4: 100000 -}, _b4 = ref5.b4, b4 = _b4 === void 0 ? 1 : _b4; -var ref6 = { +}, _b4 = ref2.b4, b4 = _b4 === void 0 ? 1 : _b4; +var ref3 = { b5: { b52: b52 } -}, _b5 = ref6.b5, b52 = _b5.b52; +}, b52 = ref3.b5.b52; function foo() { return { 1: true @@ -39,12 +39,12 @@ function bar() { 2: true }; } -var ref7 = foo(), c0 = ref7[1]; -var ref8 = bar(), c1 = ref8[1]; +var ref4 = foo(), c0 = ref4[1]; +var ref5 = bar(), c1 = ref5[1]; function foo1() { return { "prop1": 2 }; } -var ref9 = foo1(), d1 = ref9["prop1"]; -var ref10 = foo1(), d1 = ref10["prop2"]; +var ref6 = foo1(), d1 = ref6["prop1"]; +var ref7 = foo1(), d1 = ref7["prop2"]; diff --git a/tests/tsc-references/es6/destructuring/destructuringObjectBindingPatternAndAssignment1ES6/input.ts/es5.1.normal/output.js b/tests/tsc-references/es6/destructuring/destructuringObjectBindingPatternAndAssignment1ES6/input.ts/es5.1.normal/output.js index ba9f495a60d5..d1afe09ce49a 100644 --- a/tests/tsc-references/es6/destructuring/destructuringObjectBindingPatternAndAssignment1ES6/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/es6/destructuring/destructuringObjectBindingPatternAndAssignment1ES6/input.ts/es5.1.normal/output.js @@ -4,32 +4,32 @@ // V is an object assignment pattern and, for each assignment property P in V, // S is the type Any, or var a1 = undefined.a1; -var ref = { -}, a2 = ref.a2; +var a2 = { +}.a2; // V is an object assignment pattern and, for each assignment property P in V, // S has an apparent property with the property name specified in // P of a type that is assignable to the target given in P, or -var ref1 = { +var b1 = { b1: 1 -}, b1 = ref1.b1; -var ref2 = { +}.b1; +var ref = { b2: { b21: "world" } -}, tmp = ref2.b2, ref3 = tmp === void 0 ? { +}, tmp = ref.b2, b21 = (tmp === void 0 ? { b21: "string" -} : tmp, b21 = ref3.b21; -var ref4 = { +} : tmp).b21; +var ref1 = { 1: "string" -}, b3 = ref4[1]; -var ref5 = { +}, b3 = ref1[1]; +var ref2 = { b4: 100000 -}, _b4 = ref5.b4, b4 = _b4 === void 0 ? 1 : _b4; -var ref6 = { +}, _b4 = ref2.b4, b4 = _b4 === void 0 ? 1 : _b4; +var ref3 = { b5: { b52: b52 } -}, _b5 = ref6.b5, b52 = _b5.b52; +}, b52 = ref3.b5.b52; function foo() { return { 1: true @@ -40,12 +40,12 @@ function bar() { 2: true }; } -var ref7 = foo(), c0 = ref7[1]; -var ref8 = bar(), c1 = ref8[1]; +var ref4 = foo(), c0 = ref4[1]; +var ref5 = bar(), c1 = ref5[1]; function foo1() { return { "prop1": 2 }; } -var ref9 = foo1(), d1 = ref9["prop1"]; -var ref10 = foo1(), d1 = ref10["prop2"]; +var ref6 = foo1(), d1 = ref6["prop1"]; +var ref7 = foo1(), d1 = ref7["prop2"]; diff --git a/tests/tsc-references/es6/destructuring/destructuringObjectBindingPatternAndAssignment5/input.ts/es5.1.normal/output.js b/tests/tsc-references/es6/destructuring/destructuringObjectBindingPatternAndAssignment5/input.ts/es5.1.normal/output.js index 4e47b318e0e3..48a93bef3a26 100644 --- a/tests/tsc-references/es6/destructuring/destructuringObjectBindingPatternAndAssignment5/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/es6/destructuring/destructuringObjectBindingPatternAndAssignment5/input.ts/es5.1.normal/output.js @@ -32,9 +32,8 @@ function a() { var x; var y; var _tmp; - var ref; _tmp = { }, y = _objectWithoutProperties(_tmp, [ "x" - ]), ref = _tmp, x = ref.x, ref, _tmp; + ]), x = _tmp.x, _tmp; } diff --git a/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration1ES5/input.ts/es5.1.normal/output.js b/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration1ES5/input.ts/es5.1.normal/output.js index d27cc46c8dbb..de3288deb76c 100644 --- a/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration1ES5/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration1ES5/input.ts/es5.1.normal/output.js @@ -105,7 +105,7 @@ function b3(param) { j: 1 } } - } : param, _z = ref.z, x = _z.x, _y = _z.y, j = _y.j; + } : param, _z = ref.z, x = _z.x, j = _z.y.j; } function b6(param) { var ref = _slicedToArray(param === void 0 ? [ @@ -165,20 +165,20 @@ Foo1; })(Foo1 || (Foo1 = { })); function c0(param) { - var _z = param.z, x = _z.x, _y = _z.y, j = _y.j; + var _z = param.z, x = _z.x, j = _z.y.j; } function c1(param) { - var ref = param === void 0 ? { + var z = (param === void 0 ? { z: 10 - } : param, z = ref.z; + } : param).z; } function c2(param) { var _z = param.z, z = _z === void 0 ? 10 : _z; } function c3(param) { - var ref = param === void 0 ? { + var b = (param === void 0 ? { b: "hello" - } : param, b = ref.b; + } : param).b; } function c5(param) { var _param = _slicedToArray(param, 3), a = _param[0], b = _param[1], ref = _slicedToArray(_param[2], 1), ref5 = _slicedToArray(ref[0], 1), c = ref5[0]; diff --git a/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration1ES5iterable/input.ts/es5.1.normal/output.js b/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration1ES5iterable/input.ts/es5.1.normal/output.js index 9f7faf053d61..9e33296cc843 100644 --- a/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration1ES5iterable/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration1ES5iterable/input.ts/es5.1.normal/output.js @@ -106,7 +106,7 @@ function b3(param) { j: 1 } } - } : param, _z = ref.z, x = _z.x, _y = _z.y, j = _y.j; + } : param, _z = ref.z, x = _z.x, j = _z.y.j; } function b6(param) { var ref = _slicedToArray(param === void 0 ? [ @@ -166,20 +166,20 @@ Foo1; })(Foo1 || (Foo1 = { })); function c0(param) { - var _z = param.z, x = _z.x, _y = _z.y, j = _y.j; + var _z = param.z, x = _z.x, j = _z.y.j; } function c1(param) { - var ref = param === void 0 ? { + var z = (param === void 0 ? { z: 10 - } : param, z = ref.z; + } : param).z; } function c2(param) { var _z = param.z, z = _z === void 0 ? 10 : _z; } function c3(param) { - var ref = param === void 0 ? { + var b = (param === void 0 ? { b: "hello" - } : param, b = ref.b; + } : param).b; } function c5(param) { var _param = _slicedToArray(param, 3), a = _param[0], b = _param[1], ref = _slicedToArray(_param[2], 1), ref5 = _slicedToArray(ref[0], 1), c = ref5[0]; diff --git a/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration1ES6/input.ts/es5.1.normal/output.js b/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration1ES6/input.ts/es5.1.normal/output.js index a387786b9c7e..628a812c3f32 100644 --- a/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration1ES6/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration1ES6/input.ts/es5.1.normal/output.js @@ -107,7 +107,7 @@ function b3(param) { j: 1 } } - } : param, _z = ref.z, x = _z.x, _y = _z.y, j = _y.j; + } : param, _z = ref.z, x = _z.x, j = _z.y.j; } function b6(param) { var ref = _slicedToArray(param === void 0 ? [ @@ -150,20 +150,20 @@ Foo1; })(Foo1 || (Foo1 = { })); function c0(param) { - var _z = param.z, x = _z.x, _y = _z.y, j = _y.j; + var _z = param.z, x = _z.x, j = _z.y.j; } function c1(param) { - var ref = param === void 0 ? { + var z = (param === void 0 ? { z: 10 - } : param, z = ref.z; + } : param).z; } function c2(param) { var _z = param.z, z = _z === void 0 ? 10 : _z; } function c3(param) { - var ref = param === void 0 ? { + var b = (param === void 0 ? { b: "hello" - } : param, b = ref.b; + } : param).b; } function c5(param) { var _param = _slicedToArray(param, 3), a = _param[0], b = _param[1], ref = _slicedToArray(_param[2], 1), ref5 = _slicedToArray(ref[0], 1), c = ref5[0]; diff --git a/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration5/input.ts/es5.1.normal/output.js b/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration5/input.ts/es5.1.normal/output.js index c2b410d86fee..8cab328ec312 100644 --- a/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration5/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/es6/destructuring/destructuringParameterDeclaration5/input.ts/es5.1.normal/output.js @@ -71,9 +71,9 @@ var SubD = /*#__PURE__*/ function(D) { return SubD; }(D); function d0(param) { - var ref = param === void 0 ? { + var x = (param === void 0 ? { x: new Class() - } : param, x = ref.x; + } : param).x; } function d1(param) { var x = param.x; @@ -85,9 +85,9 @@ function d3(param) { var y = param.y; } function d4(param) { - var ref = param === void 0 ? { + var y = (param === void 0 ? { y: new D() - } : param, y = ref.y; + } : param).y; } var obj1 = new Class(); d0({ diff --git a/tests/tsc-references/es6/destructuring/destructuringSpread/input.ts/es5.1.normal/output.js b/tests/tsc-references/es6/destructuring/destructuringSpread/input.ts/es5.1.normal/output.js index 11ba087d3c42..585776dcf620 100644 --- a/tests/tsc-references/es6/destructuring/destructuringSpread/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/es6/destructuring/destructuringSpread/input.ts/es5.1.normal/output.js @@ -27,22 +27,22 @@ function _objectSpread(target) { } return target; } -var ref = _objectSpread({ +var x = _objectSpread({ }, { }, { x: 0 -}), x = ref.x; -var ref1 = _objectSpread({ +}).x; +var y = _objectSpread({ y: 0 }, { -}), y = ref1.y; -var ref2 = _objectSpread({ +}).y; +var ref = _objectSpread({ z: 0 }, { a: 0, b: 0 -}), z = ref2.z, a = ref2.a, b = ref2.b; -var ref3 = _objectSpread({ +}), z = ref.z, a = ref.a, b = ref.b; +var ref1 = _objectSpread({ }, _objectSpread({ }, _objectSpread({ }, { @@ -53,4 +53,4 @@ var ref3 = _objectSpread({ e: 0 }), { f: 0 -}), c = ref3.c, d = ref3.d, e = ref3.e, f = ref3.f, g = ref3.g; +}), c = ref1.c, d = ref1.d, e = ref1.e, f = ref1.f, g = ref1.g; diff --git a/tests/tsc-references/es6/destructuring/destructuringTypeAssertionsES5_1/input.ts/es5.1.normal/output.js b/tests/tsc-references/es6/destructuring/destructuringTypeAssertionsES5_1/input.ts/es5.1.normal/output.js index 316a67c7d774..e6fdad76b35d 100644 --- a/tests/tsc-references/es6/destructuring/destructuringTypeAssertionsES5_1/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/es6/destructuring/destructuringTypeAssertionsES5_1/input.ts/es5.1.normal/output.js @@ -1,2 +1,2 @@ //@target: ES5 -var ref = foo(), x = ref.x; +var x = foo().x; diff --git a/tests/tsc-references/es6/destructuring/destructuringTypeAssertionsES5_2/input.ts/es5.1.normal/output.js b/tests/tsc-references/es6/destructuring/destructuringTypeAssertionsES5_2/input.ts/es5.1.normal/output.js index 316a67c7d774..e6fdad76b35d 100644 --- a/tests/tsc-references/es6/destructuring/destructuringTypeAssertionsES5_2/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/es6/destructuring/destructuringTypeAssertionsES5_2/input.ts/es5.1.normal/output.js @@ -1,2 +1,2 @@ //@target: ES5 -var ref = foo(), x = ref.x; +var x = foo().x; diff --git a/tests/tsc-references/es6/destructuring/destructuringTypeAssertionsES5_3/input.ts/es5.1.normal/output.js b/tests/tsc-references/es6/destructuring/destructuringTypeAssertionsES5_3/input.ts/es5.1.normal/output.js index 316a67c7d774..e6fdad76b35d 100644 --- a/tests/tsc-references/es6/destructuring/destructuringTypeAssertionsES5_3/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/es6/destructuring/destructuringTypeAssertionsES5_3/input.ts/es5.1.normal/output.js @@ -1,2 +1,2 @@ //@target: ES5 -var ref = foo(), x = ref.x; +var x = foo().x; diff --git a/tests/tsc-references/es6/destructuring/destructuringTypeAssertionsES5_4/input.ts/es5.1.normal/output.js b/tests/tsc-references/es6/destructuring/destructuringTypeAssertionsES5_4/input.ts/es5.1.normal/output.js index 316a67c7d774..e6fdad76b35d 100644 --- a/tests/tsc-references/es6/destructuring/destructuringTypeAssertionsES5_4/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/es6/destructuring/destructuringTypeAssertionsES5_4/input.ts/es5.1.normal/output.js @@ -1,2 +1,2 @@ //@target: ES5 -var ref = foo(), x = ref.x; +var x = foo().x; diff --git a/tests/tsc-references/es6/destructuring/destructuringTypeAssertionsES5_5/input.ts/es5.1.normal/output.js b/tests/tsc-references/es6/destructuring/destructuringTypeAssertionsES5_5/input.ts/es5.1.normal/output.js index abcf283a8f66..2df21bf330cc 100644 --- a/tests/tsc-references/es6/destructuring/destructuringTypeAssertionsES5_5/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/es6/destructuring/destructuringTypeAssertionsES5_5/input.ts/es5.1.normal/output.js @@ -1,2 +1,2 @@ //@target: ES5 -var ref = 0, x = ref.x; +var x = 0..x; diff --git a/tests/tsc-references/es6/destructuring/destructuringTypeAssertionsES5_6/input.ts/es5.1.normal/output.js b/tests/tsc-references/es6/destructuring/destructuringTypeAssertionsES5_6/input.ts/es5.1.normal/output.js index 999e9338df2d..26d2f6a999db 100644 --- a/tests/tsc-references/es6/destructuring/destructuringTypeAssertionsES5_6/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/es6/destructuring/destructuringTypeAssertionsES5_6/input.ts/es5.1.normal/output.js @@ -1,2 +1,2 @@ //@target: ES5 -var ref = new Foo, x = ref.x; +var x = (new Foo).x; diff --git a/tests/tsc-references/es6/destructuring/destructuringTypeAssertionsES5_7/input.ts/es5.1.normal/output.js b/tests/tsc-references/es6/destructuring/destructuringTypeAssertionsES5_7/input.ts/es5.1.normal/output.js index 999e9338df2d..26d2f6a999db 100644 --- a/tests/tsc-references/es6/destructuring/destructuringTypeAssertionsES5_7/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/es6/destructuring/destructuringTypeAssertionsES5_7/input.ts/es5.1.normal/output.js @@ -1,2 +1,2 @@ //@target: ES5 -var ref = new Foo, x = ref.x; +var x = (new Foo).x; diff --git a/tests/tsc-references/es6/destructuring/destructuringVariableDeclaration1ES5/input.ts/es5.1.normal/output.js b/tests/tsc-references/es6/destructuring/destructuringVariableDeclaration1ES5/input.ts/es5.1.normal/output.js index fd715e9311af..a7c07d220f04 100644 --- a/tests/tsc-references/es6/destructuring/destructuringVariableDeclaration1ES5/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/es6/destructuring/destructuringVariableDeclaration1ES5/input.ts/es5.1.normal/output.js @@ -59,9 +59,9 @@ var ref1 = { b1: { b11: "world" } -}, tmp = ref1.b1, ref2 = tmp === void 0 ? { +}, tmp = ref1.b1, b11 = (tmp === void 0 ? { b11: "string" -} : tmp, b11 = ref2.b11; +} : tmp).b11; var temp = { t1: true, t2: "false" @@ -70,11 +70,11 @@ var tmp1 = 3, b2 = tmp1 === void 0 ? 3 : tmp1, tmp2 = false, b3 = tmp2 === void t1: false, t2: "hello" }, b4 = tmp3 === void 0 ? temp : tmp3; -var ref3 = [ +var ref2 = [ undefined, undefined, undefined -], tmp4 = ref3[0], b5 = tmp4 === void 0 ? 3 : tmp4, tmp5 = ref3[1], b6 = tmp5 === void 0 ? true : tmp5, tmp6 = ref3[2], b7 = tmp6 === void 0 ? temp : tmp6; +], tmp4 = ref2[0], b5 = tmp4 === void 0 ? 3 : tmp4, tmp5 = ref2[1], b6 = tmp5 === void 0 ? true : tmp5, tmp6 = ref2[2], b7 = tmp6 === void 0 ? temp : tmp6; // The type T associated with a binding element is determined as follows: // If the binding element is a rest element, T is an array type with // an element type E, where E is the type of the numeric index signature of S. @@ -102,12 +102,12 @@ var temp1 = [ false, true ]; -var ref4 = _slicedToArray([ +var ref3 = _slicedToArray([ 1, "string" -].concat(_toConsumableArray(temp1)), 2), d3 = ref4[0], d4 = ref4[1]; +].concat(_toConsumableArray(temp1)), 2), d3 = ref3[0], d4 = ref3[1]; // Combining both forms of destructuring, -var ref5 = { +var ref4 = { e: [ 1, 2, @@ -116,11 +116,11 @@ var ref5 = { b4: 0 } ] -}, _e1 = _slicedToArray(ref5.e, 3), e1 = _e1[0], e2 = _e1[1], tmp7 = _e1[2], e3 = tmp7 === void 0 ? { +}, _e1 = _slicedToArray(ref4.e, 3), e1 = _e1[0], e2 = _e1[1], tmp7 = _e1[2], e3 = tmp7 === void 0 ? { b1: 1000, b4: 200 } : tmp7; -var ref6 = { +var ref5 = { f: [ 1, 2, @@ -129,29 +129,29 @@ var ref6 = { f5: 0 } ] -}, _f = _slicedToArray(ref6.f, 3), f1 = _f[0], f2 = _f[1], ref7 = _f[2], f4 = ref7.f3, f5 = ref7.f5; +}, _f = _slicedToArray(ref5.f, 3), f1 = _f[0], f2 = _f[1], ref6 = _f[2], f4 = ref6.f3, f5 = ref6.f5; // When a destructuring variable declaration, binding property, or binding element specifies // an initializer expression, the type of the initializer expression is required to be assignable // to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element. -var ref8 = { +var ref7 = { g: { g1: [ 1, 2 ] } -}, _g = ref8.g, _g1 = _g.g1, g1 = _g1 === void 0 ? [ +}, _g = ref7.g, _g1 = _g.g1, g1 = _g1 === void 0 ? [ undefined, null ] : _g1; -var ref9 = { +var ref8 = { h: { h1: [ 1, 2 ] } -}, _h = ref9.h, _h1 = _h.h1, h1 = _h1 === void 0 ? [ +}, _h = ref8.h, _h1 = _h.h1, h1 = _h1 === void 0 ? [ undefined, null ] : _h1; diff --git a/tests/tsc-references/es6/destructuring/destructuringVariableDeclaration1ES5iterable/input.ts/es5.1.normal/output.js b/tests/tsc-references/es6/destructuring/destructuringVariableDeclaration1ES5iterable/input.ts/es5.1.normal/output.js index 4c6667272896..fd862dd366af 100644 --- a/tests/tsc-references/es6/destructuring/destructuringVariableDeclaration1ES5iterable/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/es6/destructuring/destructuringVariableDeclaration1ES5iterable/input.ts/es5.1.normal/output.js @@ -60,9 +60,9 @@ var ref1 = { b1: { b11: "world" } -}, tmp = ref1.b1, ref2 = tmp === void 0 ? { +}, tmp = ref1.b1, b11 = (tmp === void 0 ? { b11: "string" -} : tmp, b11 = ref2.b11; +} : tmp).b11; var temp = { t1: true, t2: "false" @@ -71,11 +71,11 @@ var tmp1 = 3, b2 = tmp1 === void 0 ? 3 : tmp1, tmp2 = false, b3 = tmp2 === void t1: false, t2: "hello" }, b4 = tmp3 === void 0 ? temp : tmp3; -var ref3 = [ +var ref2 = [ undefined, undefined, undefined -], tmp4 = ref3[0], b5 = tmp4 === void 0 ? 3 : tmp4, tmp5 = ref3[1], b6 = tmp5 === void 0 ? true : tmp5, tmp6 = ref3[2], b7 = tmp6 === void 0 ? temp : tmp6; +], tmp4 = ref2[0], b5 = tmp4 === void 0 ? 3 : tmp4, tmp5 = ref2[1], b6 = tmp5 === void 0 ? true : tmp5, tmp6 = ref2[2], b7 = tmp6 === void 0 ? temp : tmp6; // The type T associated with a binding element is determined as follows: // If the binding element is a rest element, T is an array type with // an element type E, where E is the type of the numeric index signature of S. @@ -103,12 +103,12 @@ var temp1 = [ false, true ]; -var ref4 = _slicedToArray([ +var ref3 = _slicedToArray([ 1, "string" -].concat(_toConsumableArray(temp1)), 2), d3 = ref4[0], d4 = ref4[1]; +].concat(_toConsumableArray(temp1)), 2), d3 = ref3[0], d4 = ref3[1]; // Combining both forms of destructuring, -var ref5 = { +var ref4 = { e: [ 1, 2, @@ -117,11 +117,11 @@ var ref5 = { b4: 0 } ] -}, _e1 = _slicedToArray(ref5.e, 3), e1 = _e1[0], e2 = _e1[1], tmp7 = _e1[2], e3 = tmp7 === void 0 ? { +}, _e1 = _slicedToArray(ref4.e, 3), e1 = _e1[0], e2 = _e1[1], tmp7 = _e1[2], e3 = tmp7 === void 0 ? { b1: 1000, b4: 200 } : tmp7; -var ref6 = { +var ref5 = { f: [ 1, 2, @@ -130,29 +130,29 @@ var ref6 = { f5: 0 } ] -}, _f = _slicedToArray(ref6.f, 3), f1 = _f[0], f2 = _f[1], ref7 = _f[2], f4 = ref7.f3, f5 = ref7.f5; +}, _f = _slicedToArray(ref5.f, 3), f1 = _f[0], f2 = _f[1], ref6 = _f[2], f4 = ref6.f3, f5 = ref6.f5; // When a destructuring variable declaration, binding property, or binding element specifies // an initializer expression, the type of the initializer expression is required to be assignable // to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element. -var ref8 = { +var ref7 = { g: { g1: [ 1, 2 ] } -}, _g = ref8.g, _g1 = _g.g1, g1 = _g1 === void 0 ? [ +}, _g = ref7.g, _g1 = _g.g1, g1 = _g1 === void 0 ? [ undefined, null ] : _g1; -var ref9 = { +var ref8 = { h: { h1: [ 1, 2 ] } -}, _h = ref9.h, _h1 = _h.h1, h1 = _h1 === void 0 ? [ +}, _h = ref8.h, _h1 = _h.h1, h1 = _h1 === void 0 ? [ undefined, null ] : _h1; diff --git a/tests/tsc-references/es6/destructuring/destructuringVariableDeclaration1ES6/input.ts/es5.1.normal/output.js b/tests/tsc-references/es6/destructuring/destructuringVariableDeclaration1ES6/input.ts/es5.1.normal/output.js index 06140908c180..f54ed744d4b7 100644 --- a/tests/tsc-references/es6/destructuring/destructuringVariableDeclaration1ES6/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/es6/destructuring/destructuringVariableDeclaration1ES6/input.ts/es5.1.normal/output.js @@ -60,9 +60,9 @@ var ref1 = { b1: { b11: "world" } -}, tmp = ref1.b1, ref2 = tmp === void 0 ? { +}, tmp = ref1.b1, b11 = (tmp === void 0 ? { b11: "string" -} : tmp, b11 = ref2.b11; +} : tmp).b11; var temp = { t1: true, t2: "false" @@ -71,11 +71,11 @@ var tmp1 = 3, b2 = tmp1 === void 0 ? 3 : tmp1, tmp2 = false, b3 = tmp2 === void t1: false, t2: "hello" }, b4 = tmp3 === void 0 ? temp : tmp3; -var ref3 = [ +var ref2 = [ undefined, undefined, undefined -], tmp4 = ref3[0], b5 = tmp4 === void 0 ? 3 : tmp4, tmp5 = ref3[1], b6 = tmp5 === void 0 ? true : tmp5, tmp6 = ref3[2], b7 = tmp6 === void 0 ? temp : tmp6; +], tmp4 = ref2[0], b5 = tmp4 === void 0 ? 3 : tmp4, tmp5 = ref2[1], b6 = tmp5 === void 0 ? true : tmp5, tmp6 = ref2[2], b7 = tmp6 === void 0 ? temp : tmp6; // The type T associated with a binding element is determined as follows: // If the binding element is a rest element, T is an array type with // an element type E, where E is the type of the numeric index signature of S. @@ -103,12 +103,12 @@ var temp1 = [ false, true ]; -var ref4 = _slicedToArray([ +var ref3 = _slicedToArray([ 1, "string" -].concat(_toConsumableArray(temp1)), 2), d3 = ref4[0], d4 = ref4[1]; +].concat(_toConsumableArray(temp1)), 2), d3 = ref3[0], d4 = ref3[1]; // Combining both forms of destructuring, -var ref5 = { +var ref4 = { e: [ 1, 2, @@ -117,11 +117,11 @@ var ref5 = { b4: 0 } ] -}, _e1 = _slicedToArray(ref5.e, 3), e1 = _e1[0], e2 = _e1[1], tmp7 = _e1[2], e3 = tmp7 === void 0 ? { +}, _e1 = _slicedToArray(ref4.e, 3), e1 = _e1[0], e2 = _e1[1], tmp7 = _e1[2], e3 = tmp7 === void 0 ? { b1: 1000, b4: 200 } : tmp7; -var ref6 = { +var ref5 = { f: [ 1, 2, @@ -130,29 +130,29 @@ var ref6 = { f5: 0 } ] -}, _f = _slicedToArray(ref6.f, 3), f1 = _f[0], f2 = _f[1], ref7 = _f[2], f4 = ref7.f3, f5 = ref7.f5; +}, _f = _slicedToArray(ref5.f, 3), f1 = _f[0], f2 = _f[1], ref6 = _f[2], f4 = ref6.f3, f5 = ref6.f5; // When a destructuring variable declaration, binding property, or binding element specifies // an initializer expression, the type of the initializer expression is required to be assignable // to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element. -var ref8 = { +var ref7 = { g: { g1: [ 1, 2 ] } -}, _g = ref8.g, _g1 = _g.g1, g1 = _g1 === void 0 ? [ +}, _g = ref7.g, _g1 = _g.g1, g1 = _g1 === void 0 ? [ undefined, null ] : _g1; -var ref9 = { +var ref8 = { h: { h1: [ 1, 2 ] } -}, _h = ref9.h, _h1 = _h.h1, h1 = _h1 === void 0 ? [ +}, _h = ref8.h, _h1 = _h.h1, h1 = _h1 === void 0 ? [ undefined, null ] : _h1; diff --git a/tests/tsc-references/es6/destructuring/missingAndExcessProperties/input.ts/es5.1.normal/output.js b/tests/tsc-references/es6/destructuring/missingAndExcessProperties/input.ts/es5.1.normal/output.js index 207a5100e77d..8454d606a269 100644 --- a/tests/tsc-references/es6/destructuring/missingAndExcessProperties/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/es6/destructuring/missingAndExcessProperties/input.ts/es5.1.normal/output.js @@ -35,18 +35,18 @@ function f3() { x: 0, y: 0 }, ref = ref !== null ? ref : _throw(new TypeError("Cannot destructure undefined")); - var ref11 = { + var x = { x: 0, y: 0 - }, x = ref11.x; - var ref12 = { + }.x; + var y = { x: 0, y: 0 - }, y = ref12.y; - var ref13 = { + }.y; + var ref11 = { x: 0, y: 0 - }, x = ref13.x, y = ref13.y; + }, x = ref11.x, y = ref11.y; } // Excess properties function f4() { @@ -56,19 +56,17 @@ function f4() { x: 0, y: 0 }, ref; - var ref14; - ref14 = { + x = ({ x: 0, y: 0 - }, x = ref14.x, ref14; - var ref15; - ref15 = { + }).x; + y = ({ x: 0, y: 0 - }, y = ref15.y, ref15; - var ref16; - ref16 = { + }).y; + var ref12; + ref12 = { x: 0, y: 0 - }, x = ref16.x, y = ref16.y, ref16; + }, x = ref12.x, y = ref12.y, ref12; } diff --git a/tests/tsc-references/es6/destructuring/objectBindingPatternKeywordIdentifiers05/input.ts/es5.1.normal/output.js b/tests/tsc-references/es6/destructuring/objectBindingPatternKeywordIdentifiers05/input.ts/es5.1.normal/output.js index a6f4d51a9301..9589997b2577 100644 --- a/tests/tsc-references/es6/destructuring/objectBindingPatternKeywordIdentifiers05/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/es6/destructuring/objectBindingPatternKeywordIdentifiers05/input.ts/es5.1.normal/output.js @@ -1,3 +1,3 @@ -var ref = { +var as = { as: 1 -}, as = ref.as; +}.as; diff --git a/tests/tsc-references/es6/for-ofStatements/for-of41/input.ts/es5.1.normal/output.js b/tests/tsc-references/es6/for-ofStatements/for-of41/input.ts/es5.1.normal/output.js index 41f876261a35..477132cecd39 100644 --- a/tests/tsc-references/es6/for-ofStatements/for-of41/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/es6/for-ofStatements/for-of41/input.ts/es5.1.normal/output.js @@ -43,7 +43,7 @@ var array = [ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; try { for(var _iterator = array[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ - var _value = _step.value, _x = _slicedToArray(_value.x, 1), a = _x[0], _y = _value.y, p = _y.p; + var _value = _step.value, _x = _slicedToArray(_value.x, 1), a = _x[0], p = _value.y.p; a; p; } diff --git a/tests/tsc-references/es6/for-ofStatements/for-of41/input.ts/es5.2.minified/output.js b/tests/tsc-references/es6/for-ofStatements/for-of41/input.ts/es5.2.minified/output.js index 69f73acff8e0..1d30a883d491 100644 --- a/tests/tsc-references/es6/for-ofStatements/for-of41/input.ts/es5.2.minified/output.js +++ b/tests/tsc-references/es6/for-ofStatements/for-of41/input.ts/es5.2.minified/output.js @@ -1,5 +1,16 @@ -function _slicedToArray(arr, i) { - return (function(arr) { +var _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0; +try { + for(var arr, i, _step, _iterator = [ + { + x: [ + 0 + ], + y: { + p: "" + } + } + ][Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0)var _value = _step.value; + (arr = _value.x, i = 1, (function(arr) { if (Array.isArray(arr)) return arr; })(arr) || (function(arr, i) { var _arr = [], _n = !0, _d = !1, _e = void 0; @@ -17,21 +28,7 @@ function _slicedToArray(arr, i) { return _arr; })(arr, i) || (function() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); - })(); -} -var _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0; -try { - for(var _step, _iterator = [ - { - x: [ - 0 - ], - y: { - p: "" - } - } - ][Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0)var _value = _step.value, a = _slicedToArray(_value.x, 1)[0], _y = _value.y; - _y.p; + })())[0], _value.y.p; } catch (err) { _didIteratorError = !0, _iteratorError = err; } finally{ diff --git a/tests/tsc-references/expressions/assignmentOperator/assignmentTypeNarrowing/input.ts/es5.1.normal/output.js b/tests/tsc-references/expressions/assignmentOperator/assignmentTypeNarrowing/input.ts/es5.1.normal/output.js index 813dd80f293d..7f2d2ccf4752 100644 --- a/tests/tsc-references/expressions/assignmentOperator/assignmentTypeNarrowing/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/expressions/assignmentOperator/assignmentTypeNarrowing/input.ts/es5.1.normal/output.js @@ -5,25 +5,24 @@ x = true; x; // boolean x = "" = 1; x; // string | number -var ref; -ref = { +x = ({ x: true -}, x = ref.x, ref; +}).x; x; // boolean -var ref1; -ref1 = { +var ref; +ref = { y: 1 -}, x = ref1.y, ref1; +}, x = ref.y, ref; x; // number -var ref2, ref3; -ref2 = { +var ref1, ref2; +ref1 = { x: true -}, ref3 = ref2.x, x = ref3 === void 0 ? "" : ref3, ref2; +}, ref2 = ref1.x, x = ref2 === void 0 ? "" : ref2, ref1; x; // string | boolean -var ref4; -ref4 = { +var ref3; +ref3 = { y: 1 -}, x = /a/ = ref4.y, ref4; +}, x = /a/ = ref3.y, ref3; x; // number | RegExp var a; var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; diff --git a/tests/tsc-references/expressions/functions/arrowFunctionExpressions/input.ts/es5.1.normal/output.js b/tests/tsc-references/expressions/functions/arrowFunctionExpressions/input.ts/es5.1.normal/output.js index 15b914d01f93..b7910d96721f 100644 --- a/tests/tsc-references/expressions/functions/arrowFunctionExpressions/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/expressions/functions/arrowFunctionExpressions/input.ts/es5.1.normal/output.js @@ -97,7 +97,7 @@ var p6 = function(param) { var a = param.a; }; var p7 = function(param) { - var _a = param.a, b = _a.b; + var b = param.a.b; }; var p8 = function(param) { var _a = param.a, a = _a === void 0 ? 1 : _a; diff --git a/tests/tsc-references/jsx/tsxUnionTypeComponent1x/input.tsx/es5.1.normal/output.js b/tests/tsc-references/jsx/tsxUnionTypeComponent1x/input.tsx/es5.1.normal/output.js index 492c3cfedebe..80aafff44cc4 100644 --- a/tests/tsc-references/jsx/tsxUnionTypeComponent1x/input.tsx/es5.1.normal/output.js +++ b/tests/tsc-references/jsx/tsxUnionTypeComponent1x/input.tsx/es5.1.normal/output.js @@ -75,7 +75,7 @@ var MyComponent = /*#__PURE__*/ function(_Component) { { key: "render", value: function render() { - var _props = this.props, AnyComponent = _props.AnyComponent; + var AnyComponent = this.props.AnyComponent; return(/*#__PURE__*/ React.createElement(AnyComponent, null)); } } diff --git a/tests/tsc-references/pedantic/noUncheckedIndexedAccessDestructuring/input.ts/es5.1.normal/output.js b/tests/tsc-references/pedantic/noUncheckedIndexedAccessDestructuring/input.ts/es5.1.normal/output.js index 8401b590cbdd..74dd1b66b00b 100644 --- a/tests/tsc-references/pedantic/noUncheckedIndexedAccessDestructuring/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/pedantic/noUncheckedIndexedAccessDestructuring/input.ts/es5.1.normal/output.js @@ -117,6 +117,5 @@ ref2 = strArray, target_string_arr = ref2.slice(3), ref2; // Should OK var ref3; ref3 = numMapPoint, x2 = ref3.x, y1 = ref3.y, z1 = ref3.z, ref3; // Should OK var q1; - var ref4; - ref4 = numMapPoint, q1 = ref4.q, ref4; // Should error + q1 = numMapPoint.q; // Should error } diff --git a/tests/tsc-references/salsa/commonJSImportClassTypeReference/input.ts/es5.1.normal/output.js b/tests/tsc-references/salsa/commonJSImportClassTypeReference/input.ts/es5.1.normal/output.js index 140ba8bcab1e..ecf515aa46b9 100644 --- a/tests/tsc-references/salsa/commonJSImportClassTypeReference/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/salsa/commonJSImportClassTypeReference/input.ts/es5.1.normal/output.js @@ -23,7 +23,7 @@ function _createClass(Constructor, protoProps, staticProps) { // @outDir: out // @declaration: true // @filename: main.js -var ref = require("./mod1"), K = ref.K; +var K = require("./mod1").K; /** @param {K} k */ function f(k) { k.values(); } diff --git a/tests/tsc-references/salsa/commonJSImportExportedClassExpression/input.ts/es5.1.normal/output.js b/tests/tsc-references/salsa/commonJSImportExportedClassExpression/input.ts/es5.1.normal/output.js index 3dca06b225f0..6964de690633 100644 --- a/tests/tsc-references/salsa/commonJSImportExportedClassExpression/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/salsa/commonJSImportExportedClassExpression/input.ts/es5.1.normal/output.js @@ -23,7 +23,7 @@ function _createClass(Constructor, protoProps, staticProps) { // @outDir: out // @declaration: true // @filename: main.js -var ref = require("./mod1"), K1 = ref.K; +var K1 = require("./mod1").K; /** @param {K} k */ function f(k) { k.values(); } diff --git a/tests/tsc-references/salsa/commonJSImportNestedClassTypeReference/input.ts/es5.1.normal/output.js b/tests/tsc-references/salsa/commonJSImportNestedClassTypeReference/input.ts/es5.1.normal/output.js index 7d53a5028321..a7e820744b34 100644 --- a/tests/tsc-references/salsa/commonJSImportNestedClassTypeReference/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/salsa/commonJSImportNestedClassTypeReference/input.ts/es5.1.normal/output.js @@ -23,7 +23,7 @@ function _createClass(Constructor, protoProps, staticProps) { // @outDir: out // @declaration: true // @filename: main.js -var ref = require("./mod1"), K = ref.K; +var K = require("./mod1").K; /** @param {K} k */ function f(k) { k.values(); } diff --git a/tests/tsc-references/salsa/commonJSReexport/input.ts/es5.1.normal/output.js b/tests/tsc-references/salsa/commonJSReexport/input.ts/es5.1.normal/output.js index 29ccc95cd9c8..385f414b7031 100644 --- a/tests/tsc-references/salsa/commonJSReexport/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/salsa/commonJSReexport/input.ts/es5.1.normal/output.js @@ -13,5 +13,5 @@ module.exports = { nested: require('./first') }; // @filename: main.js -var _nested = require('./second').nested, hardline = _nested.hardline; +var hardline = require('./second').nested.hardline; hardline; diff --git a/tests/tsc-references/salsa/nestedDestructuringOfRequire/input.ts/es5.1.normal/output.js b/tests/tsc-references/salsa/nestedDestructuringOfRequire/input.ts/es5.1.normal/output.js index 3923eedc743f..b77d1bae4d64 100644 --- a/tests/tsc-references/salsa/nestedDestructuringOfRequire/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/salsa/nestedDestructuringOfRequire/input.ts/es5.1.normal/output.js @@ -9,6 +9,6 @@ var chalk = { }; module.exports.chalk = chalk; // @filename: main.js -var ref = require('./mod1'), _chalk = ref.chalk, grey = _chalk.grey; +var ref = require('./mod1'), grey = ref.chalk.grey; grey; chalk; diff --git a/tests/tsc-references/salsa/typeFromParamTagForFunction/input.ts/es5.1.normal/output.js b/tests/tsc-references/salsa/typeFromParamTagForFunction/input.ts/es5.1.normal/output.js index c4ab44ebc360..b6523ebdaba0 100644 --- a/tests/tsc-references/salsa/typeFromParamTagForFunction/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/salsa/typeFromParamTagForFunction/input.ts/es5.1.normal/output.js @@ -8,7 +8,7 @@ exports.A = function() { this.x = 1; }; // @filename: a.js -var ref = require("./a-ext"), A = ref.A; +var A = require("./a-ext").A; /** @param {A} p */ function a(p) { p.x; } @@ -19,7 +19,7 @@ exports.B = function _class() { this.x = 1; }; // @filename: b.js -var ref1 = require("./b-ext"), B = ref1.B; +var B = require("./b-ext").B; /** @param {B} p */ function b(p) { p.x; } @@ -28,7 +28,7 @@ export function C() { this.x = 1; } // @filename: c.js -var ref2 = require("./c-ext"), C = ref2.C; +var C = require("./c-ext").C; /** @param {C} p */ function c(p) { p.x; } @@ -37,7 +37,7 @@ export var D = function D() { this.x = 1; }; // @filename: d.js -var ref3 = require("./d-ext"), D = ref3.D; +var D = require("./d-ext").D; /** @param {D} p */ function d(p) { p.x; } @@ -48,7 +48,7 @@ export var E = function E() { this.x = 1; }; // @filename: e.js -var ref4 = require("./e-ext"), E = ref4.E; +var E = require("./e-ext").E; /** @param {E} p */ function e(p) { p.x; } diff --git a/tests/tsc-references/types/rest/objectRest/input.ts/es5.1.normal/output.js b/tests/tsc-references/types/rest/objectRest/input.ts/es5.1.normal/output.js index 8d8f1af342c7..1503a0bd616d 100644 --- a/tests/tsc-references/types/rest/objectRest/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/types/rest/objectRest/input.ts/es5.1.normal/output.js @@ -109,13 +109,13 @@ var renamed = o2.d, d = _objectWithoutProperties(o2, [ "d" ]); var nestedrest; -var x = nestedrest.x, _n1 = nestedrest.n1, y = _n1.y, _n2 = _n1.n2, z = _n2.z, nr = _extends({ +var x = nestedrest.x, _n1 = nestedrest.n1, y = _n1.y, z = _n1.n2.z, nr = _extends({ }, nestedrest.n1.n2.n3), restrest = _objectWithoutProperties(nestedrest, [ "x", "n1" ]); var complex; -var _x = complex.x, ka = _x.ka, other = complex.y, nested = _objectWithoutProperties(complex.x, [ +var ka = complex.x.ka, other = complex.y, nested = _objectWithoutProperties(complex.x, [ "ka" ]), rest = _objectWithoutProperties(complex, [ "x", @@ -136,13 +136,12 @@ var _ref = { "x" ]); var _tmp; -var ref1; _tmp = { x: 1, y: 2 }, fresh = _objectWithoutProperties(_tmp, [ "x" -]), ref1 = _tmp, x = ref1.x, ref1, _tmp; +]), x = _tmp.x, _tmp; var Removable = /*#__PURE__*/ function() { "use strict"; function Removable() { @@ -185,11 +184,11 @@ var stillNotGreat = o[computed], soSo = o[computed2], o = _objectWithoutProperti computed2 ].map(_toPropertyKey)); var _o; -var ref2; +var ref1; _o = o, o = _objectWithoutProperties(_o, [ computed, computed2 -].map(_toPropertyKey)), ref2 = _o, stillNotGreat = ref2[computed], soSo = ref2[computed2], ref2, _o; +].map(_toPropertyKey)), ref1 = _o, stillNotGreat = ref1[computed], soSo = ref1[computed2], ref1, _o; var noContextualType = function(_param) { var _aNumber = _param.aNumber, aNumber = _aNumber === void 0 ? 12 : _aNumber, notEmptyObject = _objectWithoutProperties(_param, [ "aNumber" diff --git a/tests/tsc-references/types/rest/objectRest2/input.ts/es5.1.normal/output.js b/tests/tsc-references/types/rest/objectRest2/input.ts/es5.1.normal/output.js index 731e771c0e3a..01d7c570cf13 100644 --- a/tests/tsc-references/types/rest/objectRest2/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/types/rest/objectRest2/input.ts/es5.1.normal/output.js @@ -69,8 +69,7 @@ function rootConnection(name) { objects: 12 }; case 2: - var ref; - ref = _ctx.sent, objects = ref.objects, ref; + objects = _ctx.sent.objects; return _ctx.abrupt("return", _objectSpread({ }, connectionFromArray(objects, args))); case 4: diff --git a/tests/tsc-references/types/rest/objectRestAssignment/input.ts/es5.1.normal/output.js b/tests/tsc-references/types/rest/objectRestAssignment/input.ts/es5.1.normal/output.js index a555dbfb4a10..fb62e425d121 100644 --- a/tests/tsc-references/types/rest/objectRestAssignment/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/types/rest/objectRestAssignment/input.ts/es5.1.normal/output.js @@ -74,7 +74,7 @@ _complex = complex, nested = _objectWithoutProperties(_complex.x, [ // should be: var overEmit; // var _g = overEmit.a, [_h, ...y] = _g, nested2 = __rest(_h, []), _j = overEmit.b, { z } = _j, c = __rest(_j, ["z"]), rest2 = __rest(overEmit, ["a", "b"]); -var _a = _toArray(overEmit.a), ref1 = _a[0], ref1 = ref1 !== null ? ref1 : _throw(new TypeError("Cannot destructure undefined")), y = _a.slice(1), _b = overEmit.b, z = _b.z, nested2 = _extends({ +var _a = _toArray(overEmit.a), ref1 = _a[0], ref1 = ref1 !== null ? ref1 : _throw(new TypeError("Cannot destructure undefined")), y = _a.slice(1), z = overEmit.b.z, nested2 = _extends({ }, overEmit.a[0]), c = _objectWithoutProperties(overEmit.b, [ "z" ]), rest2 = _objectWithoutProperties(overEmit, [ diff --git a/tests/tsc-references/types/spread/objectSpreadNoTransform/input.ts/es5.1.normal/output.js b/tests/tsc-references/types/spread/objectSpreadNoTransform/input.ts/es5.1.normal/output.js index a0177a3527be..ed2a92291023 100644 --- a/tests/tsc-references/types/spread/objectSpreadNoTransform/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/types/spread/objectSpreadNoTransform/input.ts/es5.1.normal/output.js @@ -68,7 +68,6 @@ var o = _objectSpread({ var b; var rest; var _o; -var ref; _o = o, rest = _objectWithoutProperties(_o, [ "b" -]), ref = _o, b = ref.b, ref, _o; +]), b = _o.b, _o; diff --git a/tests/vercel/loader-only/2/output/index.js b/tests/vercel/loader-only/2/output/index.js index b03aab02efe9..1040a825c43a 100644 --- a/tests/vercel/loader-only/2/output/index.js +++ b/tests/vercel/loader-only/2/output/index.js @@ -6,9 +6,9 @@ import useTeam from '@swr/use-team'; export default function MyComp() { var _query = useRouter().query, projectName = _query.project; var ref = useProject(projectName), projectInfo = ref.data; - var ref1 = useTeam(), teamSlug = ref1.teamSlug; + var teamSlug = useTeam().teamSlug; var projectId = projectInfo === null || projectInfo === void 0 ? void 0 : projectInfo.id; - var ref2 = useProjectBranches(projectId), branches = ref2.data; + var ref1 = useProjectBranches(projectId), branches = ref1.data; return(/*#__PURE__*/ _jsx(_Fragment, { })); };