-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(es/transforms/compat): Fix
destructuring
(#2904)
- Loading branch information
Showing
63 changed files
with
1,509 additions
and
108 deletions.
There are no files selected for viewing
33 changes: 32 additions & 1 deletion
33
...eferences/es6/destructuring/arrayAssignmentPatternWithAny/input.ts/es5.1.normal/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,35 @@ | ||
function _arrayWithHoles(arr) { | ||
if (Array.isArray(arr)) return arr; | ||
} | ||
function _iterableToArrayLimit(arr, i) { | ||
var _arr = []; | ||
var _n = true; | ||
var _d = false; | ||
var _e = undefined; | ||
try { | ||
for(var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true){ | ||
_arr.push(_s.value); | ||
if (i && _arr.length === i) break; | ||
} | ||
} catch (err) { | ||
_d = true; | ||
_e = err; | ||
} finally{ | ||
try { | ||
if (!_n && _i["return"] != null) _i["return"](); | ||
} finally{ | ||
if (_d) throw _e; | ||
} | ||
} | ||
return _arr; | ||
} | ||
function _nonIterableRest() { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance"); | ||
} | ||
function _slicedToArray(arr, i) { | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); | ||
} | ||
var a; | ||
var x; | ||
var ref; | ||
ref = a, x = ref[0], ref; | ||
ref = _slicedToArray(a, 1), x = ref[0], ref; |
21 changes: 20 additions & 1 deletion
21
...erences/es6/destructuring/arrayAssignmentPatternWithAny/input.ts/es5.2.minified/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,20 @@ | ||
(void 0)[0]; | ||
var arr, i; | ||
(i = 1, (function(arr) { | ||
if (Array.isArray(arr)) return arr; | ||
})(arr = void 0) || (function(arr, i) { | ||
var _arr = [], _n = !0, _d = !1, _e = void 0; | ||
try { | ||
for(var _s, _i = arr[Symbol.iterator](); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !i || _arr.length !== i); _n = !0); | ||
} catch (err) { | ||
_d = !0, _e = err; | ||
} finally{ | ||
try { | ||
_n || null == _i.return || _i.return(); | ||
} finally{ | ||
if (_d) throw _e; | ||
} | ||
} | ||
return _arr; | ||
})(arr, i) || (function() { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance"); | ||
})())[0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 32 additions & 1 deletion
33
...eferences/es6/destructuring/emptyAssignmentPatterns01_ES5/input.ts/es5.1.normal/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
var arr, i; | ||
i = 0, (function(arr) { | ||
if (Array.isArray(arr)) return arr; | ||
})(arr = void 0) || (function(arr, i) { | ||
var _arr = [], _n = !0, _d = !1, _e = void 0; | ||
try { | ||
for(var _s, _i = arr[Symbol.iterator](); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !i || _arr.length !== i); _n = !0); | ||
} catch (err) { | ||
_d = !0, _e = err; | ||
} finally{ | ||
try { | ||
_n || null == _i.return || _i.return(); | ||
} finally{ | ||
if (_d) throw _e; | ||
} | ||
} | ||
return _arr; | ||
})(arr, i) || (function() { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance"); | ||
})(); |
33 changes: 32 additions & 1 deletion
33
...s/es6/destructuring/emptyAssignmentPatterns01_ES5iterable/input.ts/es5.1.normal/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,39 @@ | ||
function _arrayWithHoles(arr) { | ||
if (Array.isArray(arr)) return arr; | ||
} | ||
function _iterableToArrayLimit(arr, i) { | ||
var _arr = []; | ||
var _n = true; | ||
var _d = false; | ||
var _e = undefined; | ||
try { | ||
for(var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true){ | ||
_arr.push(_s.value); | ||
if (i && _arr.length === i) break; | ||
} | ||
} catch (err) { | ||
_d = true; | ||
_e = err; | ||
} finally{ | ||
try { | ||
if (!_n && _i["return"] != null) _i["return"](); | ||
} finally{ | ||
if (_d) throw _e; | ||
} | ||
} | ||
return _arr; | ||
} | ||
function _nonIterableRest() { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance"); | ||
} | ||
function _slicedToArray(arr, i) { | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); | ||
} | ||
// @target: es5 | ||
// @declaration: true | ||
// @downlevelIteration: true | ||
var a; | ||
var ref; | ||
ref = a, ref; | ||
var ref1; | ||
ref1 = a, ref1; | ||
ref1 = _slicedToArray(a, 0), ref1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
var arr, i; | ||
i = 0, (function(arr) { | ||
if (Array.isArray(arr)) return arr; | ||
})(arr = void 0) || (function(arr, i) { | ||
var _arr = [], _n = !0, _d = !1, _e = void 0; | ||
try { | ||
for(var _s, _i = arr[Symbol.iterator](); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !i || _arr.length !== i); _n = !0); | ||
} catch (err) { | ||
_d = !0, _e = err; | ||
} finally{ | ||
try { | ||
_n || null == _i.return || _i.return(); | ||
} finally{ | ||
if (_d) throw _e; | ||
} | ||
} | ||
return _arr; | ||
})(arr, i) || (function() { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance"); | ||
})(); |
33 changes: 32 additions & 1 deletion
33
...eferences/es6/destructuring/emptyAssignmentPatterns01_ES6/input.ts/es5.1.normal/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,38 @@ | ||
function _arrayWithHoles(arr) { | ||
if (Array.isArray(arr)) return arr; | ||
} | ||
function _iterableToArrayLimit(arr, i) { | ||
var _arr = []; | ||
var _n = true; | ||
var _d = false; | ||
var _e = undefined; | ||
try { | ||
for(var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true){ | ||
_arr.push(_s.value); | ||
if (i && _arr.length === i) break; | ||
} | ||
} catch (err) { | ||
_d = true; | ||
_e = err; | ||
} finally{ | ||
try { | ||
if (!_n && _i["return"] != null) _i["return"](); | ||
} finally{ | ||
if (_d) throw _e; | ||
} | ||
} | ||
return _arr; | ||
} | ||
function _nonIterableRest() { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance"); | ||
} | ||
function _slicedToArray(arr, i) { | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); | ||
} | ||
// @target: es6 | ||
// @declaration: true | ||
var a; | ||
var ref; | ||
ref = a, ref; | ||
var ref1; | ||
ref1 = a, ref1; | ||
ref1 = _slicedToArray(a, 0), ref1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
var arr, i; | ||
i = 0, (function(arr) { | ||
if (Array.isArray(arr)) return arr; | ||
})(arr = void 0) || (function(arr, i) { | ||
var _arr = [], _n = !0, _d = !1, _e = void 0; | ||
try { | ||
for(var _s, _i = arr[Symbol.iterator](); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !i || _arr.length !== i); _n = !0); | ||
} catch (err) { | ||
_d = !0, _e = err; | ||
} finally{ | ||
try { | ||
_n || null == _i.return || _i.return(); | ||
} finally{ | ||
if (_d) throw _e; | ||
} | ||
} | ||
return _arr; | ||
})(arr, i) || (function() { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance"); | ||
})(); |
33 changes: 32 additions & 1 deletion
33
...eferences/es6/destructuring/emptyAssignmentPatterns02_ES5/input.ts/es5.1.normal/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,39 @@ | ||
function _arrayWithHoles(arr) { | ||
if (Array.isArray(arr)) return arr; | ||
} | ||
function _iterableToArrayLimit(arr, i) { | ||
var _arr = []; | ||
var _n = true; | ||
var _d = false; | ||
var _e = undefined; | ||
try { | ||
for(var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true){ | ||
_arr.push(_s.value); | ||
if (i && _arr.length === i) break; | ||
} | ||
} catch (err) { | ||
_d = true; | ||
_e = err; | ||
} finally{ | ||
try { | ||
if (!_n && _i["return"] != null) _i["return"](); | ||
} finally{ | ||
if (_d) throw _e; | ||
} | ||
} | ||
return _arr; | ||
} | ||
function _nonIterableRest() { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance"); | ||
} | ||
function _slicedToArray(arr, i) { | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); | ||
} | ||
// @target: es5 | ||
// @declaration: true | ||
var a; | ||
var x, y, z, a1, a2, a3; | ||
var ref, ref1; | ||
ref1 = (ref = a, x = ref.x, y = ref.y, z = ref.z, ref), ref1; | ||
var ref2, ref3; | ||
ref3 = (ref2 = a, a1 = ref2[0], a2 = ref2[1], a3 = ref2[2], ref2), ref3; | ||
ref3 = _slicedToArray((ref2 = _slicedToArray(a, 3), a1 = ref2[0], a2 = ref2[1], a3 = ref2[2], ref2), 0), ref3; |
23 changes: 22 additions & 1 deletion
23
...erences/es6/destructuring/emptyAssignmentPatterns02_ES5/input.ts/es5.2.minified/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,23 @@ | ||
var a, ref, ref1; | ||
(ref = a).x, ref.y, ref.z, (ref1 = a)[0], ref1[1], ref1[2]; | ||
function _slicedToArray(arr, i) { | ||
return (function(arr) { | ||
if (Array.isArray(arr)) return arr; | ||
})(arr) || (function(arr, i) { | ||
var _arr = [], _n = !0, _d = !1, _e = void 0; | ||
try { | ||
for(var _s, _i = arr[Symbol.iterator](); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !i || _arr.length !== i); _n = !0); | ||
} catch (err) { | ||
_d = !0, _e = err; | ||
} finally{ | ||
try { | ||
_n || null == _i.return || _i.return(); | ||
} finally{ | ||
if (_d) throw _e; | ||
} | ||
} | ||
return _arr; | ||
})(arr, i) || (function() { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance"); | ||
})(); | ||
} | ||
(ref = a).x, ref.y, ref.z, _slicedToArray(((ref1 = _slicedToArray(a, 3))[0], ref1[1], ref1[2], ref1), 0); |
Oops, something went wrong.
0c1f2eb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benchmark
base_tr_fixer
26214
ns/iter (± 2238
)25549
ns/iter (± 2288
)1.03
base_tr_resolver_and_hygiene
157734
ns/iter (± 7096
)156391
ns/iter (± 11914
)1.01
codegen_es2015
60604
ns/iter (± 1839
)58224
ns/iter (± 5363
)1.04
codegen_es2016
60178
ns/iter (± 1802
)56387
ns/iter (± 13775
)1.07
codegen_es2017
57352
ns/iter (± 3697
)59270
ns/iter (± 5998
)0.97
codegen_es2018
59072
ns/iter (± 2444
)57604
ns/iter (± 4603
)1.03
codegen_es2019
59773
ns/iter (± 4065
)59627
ns/iter (± 5093
)1.00
codegen_es2020
58947
ns/iter (± 1996
)58763
ns/iter (± 4012
)1.00
codegen_es3
59749
ns/iter (± 2235
)57589
ns/iter (± 5438
)1.04
codegen_es5
59727
ns/iter (± 2533
)59186
ns/iter (± 5620
)1.01
full_es2015
205532445
ns/iter (± 10127881
)203272461
ns/iter (± 13445180
)1.01
full_es2016
166106500
ns/iter (± 8838306
)166720190
ns/iter (± 12917291
)1.00
full_es2017
175147187
ns/iter (± 15543417
)172793804
ns/iter (± 8730481
)1.01
full_es2018
176808307
ns/iter (± 7732845
)170826603
ns/iter (± 10976370
)1.04
full_es2019
172383489
ns/iter (± 7260799
)170808879
ns/iter (± 12256751
)1.01
full_es2020
171894193
ns/iter (± 13445366
)167974141
ns/iter (± 10435754
)1.02
full_es3
245379097
ns/iter (± 18682772
)238566509
ns/iter (± 18931466
)1.03
full_es5
228844045
ns/iter (± 12467285
)219160850
ns/iter (± 18653659
)1.04
parser
777327
ns/iter (± 37967
)761678
ns/iter (± 71072
)1.02
ser_ast_node
175
ns/iter (± 8
)167
ns/iter (± 19
)1.05
ser_serde
177
ns/iter (± 6
)171
ns/iter (± 18
)1.04
emit_colors
19834451
ns/iter (± 25679064
)5092563
ns/iter (± 3869915
)3.89
emit_large
105398381
ns/iter (± 160037359
)124652448
ns/iter (± 183307347
)0.85
base_clone
2955990
ns/iter (± 199392
)2683281
ns/iter (± 163463
)1.10
fold_span
4825818
ns/iter (± 632443
)4333699
ns/iter (± 457838
)1.11
fold_span_panic
4820092
ns/iter (± 495848
)4468267
ns/iter (± 453939
)1.08
visit_mut_span
3402290
ns/iter (± 226174
)3264143
ns/iter (± 315673
)1.04
visit_mut_span_panic
3487103
ns/iter (± 288807
)3282904
ns/iter (± 256781
)1.06
ast_clone
19826
ns/iter (± 4208
)19310
ns/iter (± 2170
)1.03
ast_clone_to_stable
56907
ns/iter (± 3479
)58268
ns/iter (± 5914
)0.98
ast_clone_to_stable_then_to_unstable
108462
ns/iter (± 8460
)107257
ns/iter (± 10923
)1.01
json_deserialize
2236473
ns/iter (± 158656
)2175393
ns/iter (± 226826
)1.03
json_serialize
104357
ns/iter (± 8085
)106174
ns/iter (± 13749
)0.98
boxing_boxed
148
ns/iter (± 6
)134
ns/iter (± 12
)1.10
boxing_boxed_clone
81
ns/iter (± 2
)74
ns/iter (± 7
)1.09
boxing_unboxed
132
ns/iter (± 1
)125
ns/iter (± 14
)1.06
boxing_unboxed_clone
74
ns/iter (± 1
)69
ns/iter (± 7
)1.07
time_10
379
ns/iter (± 4
)352
ns/iter (± 39
)1.08
time_15
791
ns/iter (± 4
)764
ns/iter (± 107
)1.04
time_20
1369
ns/iter (± 56
)1367
ns/iter (± 77
)1.00
time_40
4947
ns/iter (± 47
)4828
ns/iter (± 339
)1.02
time_5
120
ns/iter (± 1
)120
ns/iter (± 5
)1
time_60
10355
ns/iter (± 154
)10279
ns/iter (± 333
)1.01
This comment was automatically generated by workflow using github-action-benchmark.
0c1f2eb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold
2
.emit_colors
19834451
ns/iter (± 25679064
)5092563
ns/iter (± 3869915
)3.89
This comment was automatically generated by workflow using github-action-benchmark.
CC: @kdy1