Skip to content

Commit 4644d00

Browse files
authoredJun 14, 2023
fix(es/compat): Fix handling of this of optional chaining pass (#7527)
**Related issue:** - Closes #7526.
1 parent db85bf3 commit 4644d00

File tree

66 files changed

+531
-478
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+531
-478
lines changed
 

‎crates/swc/tests/fixture/issues-1xxx/1333/case3/output/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ class RequestHandler {
7575
* @param {Response} res
7676
* @return {* | Promise<any>}
7777
*/ static async parseResponse(res) {
78-
var _res_headers_get_startsWith, _object;
79-
if ((_object = res.headers.get("Content-Type")) === null || _object === void 0 ? void 0 : (_res_headers_get_startsWith = _object.startsWith) === null || _res_headers_get_startsWith === void 0 ? void 0 : _res_headers_get_startsWith.call(_object, "application/json")) {
78+
var _res_headers_get_startsWith, _this;
79+
if ((_this = res.headers.get("Content-Type")) === null || _this === void 0 ? void 0 : (_res_headers_get_startsWith = _this.startsWith) === null || _res_headers_get_startsWith === void 0 ? void 0 : _res_headers_get_startsWith.call(_this, "application/json")) {
8080
return await res.json();
8181
}
8282
return res.buffer();

‎crates/swc/tests/fixture/issues-3xxx/3381/1/output/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ var dummyTsFunction = function() {
66
];
77
var func1 = function(array) {
88
var // Mapping array
9-
_array_map, _object;
10-
return (_object = array) === null || _object === void 0 ? void 0 : (_array_map = _object.map) === null || _array_map === void 0 ? void 0 : _array_map.call(_object, function(i) {
9+
_array_map, _this;
10+
return (_this = array) === null || _this === void 0 ? void 0 : (_array_map = _this.map) === null || _array_map === void 0 ? void 0 : _array_map.call(_this, function(i) {
1111
return i;
1212
});
1313
};
1414
var func2 = function(array) {
15-
var _array_map, _object;
16-
return (_object = array) === null || _object === void 0 ? void 0 : (_array_map = _object.map) === null || _array_map === void 0 ? void 0 : _array_map.call(_object, function(i) {
15+
var _array_map, _this;
16+
return (_this = array) === null || _this === void 0 ? void 0 : (_array_map = _this.map) === null || _array_map === void 0 ? void 0 : _array_map.call(_this, function(i) {
1717
return i;
1818
});
1919
};

1 commit comments

Comments
 (1)

github-actions[bot] commented on Jun 14, 2023

@github-actions[bot]

Benchmark

Benchmark suite Current: 4644d00 Previous: f27838d Ratio
es/full/bugs-1 304153 ns/iter (± 5492) 317042 ns/iter (± 7753) 0.96
es/full/minify/libraries/antd 1483866841 ns/iter (± 18861783) 1492830900 ns/iter (± 28797005) 0.99
es/full/minify/libraries/d3 322636044 ns/iter (± 3794972) 323177948 ns/iter (± 6486912) 1.00
es/full/minify/libraries/echarts 1198622962 ns/iter (± 14568743) 1251407043 ns/iter (± 25688308) 0.96
es/full/minify/libraries/jquery 95340550 ns/iter (± 253333) 95637290 ns/iter (± 289119) 1.00
es/full/minify/libraries/lodash 113368652 ns/iter (± 684447) 113125586 ns/iter (± 237849) 1.00
es/full/minify/libraries/moment 56008518 ns/iter (± 167457) 55908784 ns/iter (± 406839) 1.00
es/full/minify/libraries/react 20048551 ns/iter (± 289696) 19933956 ns/iter (± 114751) 1.01
es/full/minify/libraries/terser 253682300 ns/iter (± 3082147) 248905908 ns/iter (± 1444078) 1.02
es/full/minify/libraries/three 451636968 ns/iter (± 4999127) 445902266 ns/iter (± 4048498) 1.01
es/full/minify/libraries/typescript 3060965657 ns/iter (± 30418870) 3023212183 ns/iter (± 13882931) 1.01
es/full/minify/libraries/victory 668433489 ns/iter (± 15808709) 654525186 ns/iter (± 8979780) 1.02
es/full/minify/libraries/vue 139537256 ns/iter (± 1150223) 138219102 ns/iter (± 524785) 1.01
es/full/codegen/es3 37524 ns/iter (± 81) 36048 ns/iter (± 48) 1.04
es/full/codegen/es5 37370 ns/iter (± 97) 36145 ns/iter (± 37) 1.03
es/full/codegen/es2015 37641 ns/iter (± 102) 36096 ns/iter (± 34) 1.04
es/full/codegen/es2016 37693 ns/iter (± 77) 36120 ns/iter (± 59) 1.04
es/full/codegen/es2017 37668 ns/iter (± 86) 36140 ns/iter (± 38) 1.04
es/full/codegen/es2018 37534 ns/iter (± 155) 36085 ns/iter (± 25) 1.04
es/full/codegen/es2019 37528 ns/iter (± 70) 36120 ns/iter (± 60) 1.04
es/full/codegen/es2020 37631 ns/iter (± 100) 36109 ns/iter (± 62) 1.04
es/full/all/es3 186101369 ns/iter (± 1140863) 184918253 ns/iter (± 610525) 1.01
es/full/all/es5 176629216 ns/iter (± 918711) 174343686 ns/iter (± 425514) 1.01
es/full/all/es2015 131638514 ns/iter (± 854114) 129807947 ns/iter (± 2246396) 1.01
es/full/all/es2016 130670730 ns/iter (± 660325) 128029222 ns/iter (± 5940546) 1.02
es/full/all/es2017 129222869 ns/iter (± 760088) 127699044 ns/iter (± 400908) 1.01
es/full/all/es2018 127492029 ns/iter (± 1094307) 125105612 ns/iter (± 1053662) 1.02
es/full/all/es2019 126626378 ns/iter (± 878091) 124150425 ns/iter (± 2117545) 1.02
es/full/all/es2020 120929211 ns/iter (± 714934) 118057402 ns/iter (± 718165) 1.02
es/full/parser 534422 ns/iter (± 8838) 518214 ns/iter (± 6002) 1.03
es/full/base/fixer 18489 ns/iter (± 159) 19063 ns/iter (± 96) 0.97
es/full/base/resolver_and_hygiene 95376 ns/iter (± 236) 97591 ns/iter (± 177) 0.98
serialization of serde 330 ns/iter (± 3) 322 ns/iter (± 0) 1.02
css/minify/libraries/bootstrap 31533365 ns/iter (± 136321) 30778258 ns/iter (± 56926) 1.02
css/visitor/compare/clone 1908555 ns/iter (± 3662) 2150104 ns/iter (± 22458) 0.89
css/visitor/compare/visit_mut_span 2039449 ns/iter (± 4434) 2277019 ns/iter (± 13137) 0.90
css/visitor/compare/visit_mut_span_panic 2099463 ns/iter (± 7405) 2350969 ns/iter (± 9275) 0.89
css/visitor/compare/fold_span 2810600 ns/iter (± 10350) 3073902 ns/iter (± 14027) 0.91
css/visitor/compare/fold_span_panic 2991807 ns/iter (± 6880) 3261584 ns/iter (± 17434) 0.92
css/lexer/bootstrap_5_1_3 4787743 ns/iter (± 6245) 4825486 ns/iter (± 5044) 0.99
css/lexer/foundation_6_7_4 4023698 ns/iter (± 1445) 4046287 ns/iter (± 3373) 0.99
css/lexer/tailwind_3_1_1 758971 ns/iter (± 472) 766194 ns/iter (± 661) 0.99
css/parser/bootstrap_5_1_3 21234058 ns/iter (± 79725) 20501078 ns/iter (± 39359) 1.04
css/parser/foundation_6_7_4 17142011 ns/iter (± 110602) 16491020 ns/iter (± 21278) 1.04
css/parser/tailwind_3_1_1 3266860 ns/iter (± 2665) 3181845 ns/iter (± 5075) 1.03
es/codegen/colors 740595 ns/iter (± 405685) 747936 ns/iter (± 406847) 0.99
es/codegen/large 2974969 ns/iter (± 1555976) 2994136 ns/iter (± 1567729) 0.99
es/codegen/with-parser/colors 48633 ns/iter (± 245) 49013 ns/iter (± 240) 0.99
es/codegen/with-parser/large 520329 ns/iter (± 1213) 523244 ns/iter (± 1907) 0.99
es/minify/libraries/antd 1373784564 ns/iter (± 15447253) 1344682343 ns/iter (± 15284231) 1.02
es/minify/libraries/d3 289879623 ns/iter (± 2409954) 283031686 ns/iter (± 2319135) 1.02
es/minify/libraries/echarts 1098689486 ns/iter (± 20179284) 1068231984 ns/iter (± 8804745) 1.03
es/minify/libraries/jquery 84681972 ns/iter (± 481124) 83633708 ns/iter (± 1390727) 1.01
es/minify/libraries/lodash 103490408 ns/iter (± 685998) 102590159 ns/iter (± 705025) 1.01
es/minify/libraries/moment 49782963 ns/iter (± 208181) 49316130 ns/iter (± 295781) 1.01
es/minify/libraries/react 18103758 ns/iter (± 158160) 17995774 ns/iter (± 51998) 1.01
es/minify/libraries/terser 220545445 ns/iter (± 1783880) 213972857 ns/iter (± 3017575) 1.03
es/minify/libraries/three 391970013 ns/iter (± 11399270) 372907889 ns/iter (± 4552952) 1.05
es/minify/libraries/typescript 2653505154 ns/iter (± 26088567) 2628873243 ns/iter (± 35774795) 1.01
es/minify/libraries/victory 561335882 ns/iter (± 7232721) 561996173 ns/iter (± 6159853) 1.00
es/minify/libraries/vue 123574005 ns/iter (± 481431) 124315160 ns/iter (± 680230) 0.99
es/visitor/compare/clone 2082514 ns/iter (± 4419) 2080928 ns/iter (± 6410) 1.00
es/visitor/compare/visit_mut_span 2407077 ns/iter (± 4154) 2425487 ns/iter (± 5337) 0.99
es/visitor/compare/visit_mut_span_panic 2447509 ns/iter (± 4947) 2458516 ns/iter (± 31563) 1.00
es/visitor/compare/fold_span 3494593 ns/iter (± 15800) 3510927 ns/iter (± 6169) 1.00
es/visitor/compare/fold_span_panic 3623796 ns/iter (± 8011) 3640449 ns/iter (± 10566) 1.00
es/lexer/colors 13701 ns/iter (± 57) 12953 ns/iter (± 59) 1.06
es/lexer/angular 6238422 ns/iter (± 7134) 6171042 ns/iter (± 11526) 1.01
es/lexer/backbone 816793 ns/iter (± 1078) 815149 ns/iter (± 1369) 1.00
es/lexer/jquery 4604799 ns/iter (± 6412) 4554987 ns/iter (± 9265) 1.01
es/lexer/jquery mobile 7165857 ns/iter (± 27693) 6968123 ns/iter (± 3817) 1.03
es/lexer/mootools 3705602 ns/iter (± 6676) 3608441 ns/iter (± 5999) 1.03
es/lexer/underscore 677531 ns/iter (± 536) 672431 ns/iter (± 1975) 1.01
es/lexer/three 21646259 ns/iter (± 34290) 21201018 ns/iter (± 82732) 1.02
es/lexer/yui 4122236 ns/iter (± 24919) 3970518 ns/iter (± 23423) 1.04
es/parser/colors 28695 ns/iter (± 54) 28972 ns/iter (± 78) 0.99
es/parser/angular 14476910 ns/iter (± 83322) 14525690 ns/iter (± 95800) 1.00
es/parser/backbone 2158027 ns/iter (± 15551) 2171687 ns/iter (± 11438) 0.99
es/parser/jquery 11753321 ns/iter (± 141887) 11811699 ns/iter (± 67566) 1.00
es/parser/jquery mobile 17911411 ns/iter (± 128245) 17945633 ns/iter (± 132165) 1.00
es/parser/mootools 8941969 ns/iter (± 13093) 9025152 ns/iter (± 18455) 0.99
es/parser/underscore 1858513 ns/iter (± 9840) 1874348 ns/iter (± 16099) 0.99
es/parser/three 50145851 ns/iter (± 923798) 50774988 ns/iter (± 328351) 0.99
es/parser/yui 9009624 ns/iter (± 25834) 9119998 ns/iter (± 34178) 0.99
es/preset-env/usage/builtin_type 146247 ns/iter (± 31827) 148074 ns/iter (± 32503) 0.99
es/preset-env/usage/property 20214 ns/iter (± 213) 20003 ns/iter (± 127) 1.01
es/resolver/typescript 98610800 ns/iter (± 1371640) 95664899 ns/iter (± 616146) 1.03
es/fixer/typescript 68243156 ns/iter (± 743360) 66521012 ns/iter (± 469027) 1.03
es/hygiene/typescript 147722709 ns/iter (± 1297027) 144064813 ns/iter (± 667238) 1.03
es/resolver_with_hygiene/typescript 310760166 ns/iter (± 3457144) 304884344 ns/iter (± 1858128) 1.02
es/visitor/base-perf/module_clone 60857 ns/iter (± 190) 61007 ns/iter (± 251) 1.00
es/visitor/base-perf/fold_empty 65258 ns/iter (± 517) 65188 ns/iter (± 585) 1.00
es/visitor/base-perf/fold_noop_impl_all 65040 ns/iter (± 297) 65262 ns/iter (± 382) 1.00
es/visitor/base-perf/fold_noop_impl_vec 64999 ns/iter (± 263) 64948 ns/iter (± 190) 1.00
es/visitor/base-perf/boxing_boxed_clone 56 ns/iter (± 0) 56 ns/iter (± 0) 1
es/visitor/base-perf/boxing_unboxed_clone 39 ns/iter (± 0) 40 ns/iter (± 0) 0.97
es/visitor/base-perf/boxing_boxed 113 ns/iter (± 0) 110 ns/iter (± 0) 1.03
es/visitor/base-perf/boxing_unboxed 80 ns/iter (± 0) 79 ns/iter (± 0) 1.01
es/visitor/base-perf/visit_empty 0 ns/iter (± 0) 0 ns/iter (± 0) NaN
es/visitor/base-perf/visit_contains_this 2579 ns/iter (± 20) 2584 ns/iter (± 5) 1.00
es/base/parallel/resolver/typescript 4773739493 ns/iter (± 270617512) 4487328989 ns/iter (± 280791301) 1.06
es/base/parallel/hygiene/typescript 1582708842 ns/iter (± 15121568) 1585503298 ns/iter (± 18656642) 1.00
misc/visitors/time-complexity/time 5 103 ns/iter (± 1) 109 ns/iter (± 0) 0.94
misc/visitors/time-complexity/time 10 278 ns/iter (± 0) 287 ns/iter (± 0) 0.97
misc/visitors/time-complexity/time 15 615 ns/iter (± 2) 560 ns/iter (± 0) 1.10
misc/visitors/time-complexity/time 20 1083 ns/iter (± 68) 1048 ns/iter (± 13) 1.03
misc/visitors/time-complexity/time 40 3749 ns/iter (± 320) 3821 ns/iter (± 323) 0.98
misc/visitors/time-complexity/time 60 9293 ns/iter (± 652) 9572 ns/iter (± 7) 0.97
es/full-target/es2016 245479 ns/iter (± 583) 240902 ns/iter (± 560) 1.02
es/full-target/es2017 230924 ns/iter (± 672) 228909 ns/iter (± 1062) 1.01
es/full-target/es2018 217762 ns/iter (± 934) 217202 ns/iter (± 1530) 1.00
es2020_nullish_coalescing 71325 ns/iter (± 282) 72858 ns/iter (± 490) 0.98
es2020_optional_chaining 88265 ns/iter (± 352) 89401 ns/iter (± 316) 0.99
es2022_class_properties 121790 ns/iter (± 416) 121969 ns/iter (± 531) 1.00
es2018_object_rest_spread 73966 ns/iter (± 444) 77166 ns/iter (± 148) 0.96
es2019_optional_catch_binding 64932 ns/iter (± 179) 65565 ns/iter (± 274) 0.99
es2017_async_to_generator 65540 ns/iter (± 226) 65917 ns/iter (± 209) 0.99
es2016_exponentiation 70373 ns/iter (± 142) 71254 ns/iter (± 319) 0.99
es2015_arrow 72670 ns/iter (± 299) 74296 ns/iter (± 170) 0.98
es2015_block_scoped_fn 69991 ns/iter (± 342) 70933 ns/iter (± 232) 0.99
es2015_block_scoping 133108 ns/iter (± 482) 134190 ns/iter (± 318) 0.99

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.