Skip to content

Commit

Permalink
test(es): Update tsc test suite (#7323)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Apr 24, 2023
1 parent 923ed13 commit 603f22d
Show file tree
Hide file tree
Showing 70 changed files with 19,227 additions and 3,072 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//// [allowImportingTypesDtsExtension.ts]
//// [/types.d.ts]
export { };
//// [/a.ts]
export var user = {
name: "John"
};
export function getUser() {
return user;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//// [allowImportingTypesDtsExtension.ts]
//// [/types.d.ts]
export { };
//// [/a.ts]
export var user = {
name: "John"
};
export function getUser() {
return user;
}
65 changes: 65 additions & 0 deletions crates/swc/tests/tsc-references/arraySpreadInCall.1.normal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//// [arraySpreadInCall.ts]
var _action;
f1.apply(void 0, [
1,
2,
3,
4,
5,
6
]);
f1.apply(void 0, [
1,
2,
3,
4,
5,
6
]);
f1.apply(void 0, [
1,
2,
3,
4,
5,
6
]);
f1.apply(void 0, [
1,
2,
3,
4,
5,
6
]);
f1.apply(void 0, [
1,
2,
3,
4,
5,
6
]);
var x21 = f2.apply(void 0, [
1,
"foo"
]);
var x22 = f2.apply(void 0, [
true,
1,
"foo"
]);
var x31 = f3.apply(void 0, [
1,
"foo"
]);
var x32 = f3.apply(void 0, [
true,
1,
"foo"
]);
(_action = action).run.apply(_action, [
100,
"foo"
] // error
);
55 changes: 55 additions & 0 deletions crates/swc/tests/tsc-references/arraySpreadInCall.2.minified.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//// [arraySpreadInCall.ts]
var _action;
f1.apply(void 0, [
1,
2,
3,
4,
5,
6
]), f1.apply(void 0, [
1,
2,
3,
4,
5,
6
]), f1.apply(void 0, [
1,
2,
3,
4,
5,
6
]), f1.apply(void 0, [
1,
2,
3,
4,
5,
6
]), f1.apply(void 0, [
1,
2,
3,
4,
5,
6
]), f2.apply(void 0, [
1,
"foo"
]), f2.apply(void 0, [
!0,
1,
"foo"
]), f3.apply(void 0, [
1,
"foo"
]), f3.apply(void 0, [
!0,
1,
"foo"
]), (_action = action).run.apply(_action, [
100,
"foo"
]);
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//// [checkJsxChildrenProperty16.tsx]
//!
//! x Import assignment cannot be used when targeting ECMAScript modules. Consider using `import * as ns from "mod"`, `import {a} from "mod"`, `import d from "mod"`, or another module format instead.
//! ,-[3:1]
//! 3 |
//! 4 | // repro from #53493
//! 5 |
//! 6 | import React = require('react');
//! : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//! 7 |
//! 8 | export type Props =
//! 9 | | { renderNumber?: false; children: (arg: string) => void }
//! `----
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//// [checkJsxChildrenProperty16.tsx]
//!
//! x Import assignment cannot be used when targeting ECMAScript modules. Consider using `import * as ns from "mod"`, `import {a} from "mod"`, `import d from "mod"`, or another module format instead.
//! ,-[3:1]
//! 3 |
//! 4 | // repro from #53493
//! 5 |
//! 6 | import React = require('react');
//! : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//! 7 |
//! 8 | export type Props =
//! 9 | | { renderNumber?: false; children: (arg: string) => void }
//! `----
69 changes: 69 additions & 0 deletions crates/swc/tests/tsc-references/contextualTypeTupleEnd.1.normal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
//// [contextualTypeTupleEnd.ts]
f1(); // Error
f1(function(x) {
return str(x);
});
f1(function(x) {
return num(x);
}, function(x) {
return str(x);
});
f1(function(x) {
return num(x);
}, function(x) {
return num(x);
}, function(x) {
return str(x);
});
var a0 = []; // Error
var a1 = [
function(x) {
return str(x);
}
];
var a2 = [
function(x) {
return num(x);
},
function(x) {
return str(x);
}
];
var a3 = [
function(x) {
return num(x);
},
function(x) {
return num(x);
},
function(x) {
return str(x);
}
];
export function createSelector() {
for(var _len = arguments.length, selectors = new Array(_len), _key = 0; _key < _len; _key++){
selectors[_key] = arguments[_key];
}
console.log(selectors);
}
createSelector(function(x) {
return x.foo;
}, function(x) {
return x.bar;
}, function() {
return 42;
});
example(function(x) {
return x.foo;
}, function(x) {
return x.bar;
}, function(x) {
return x.baz;
});
test(function(a) {
return a;
}, function(b) {
return b;
}, function(c) {
return c;
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//// [contextualTypeTupleEnd.ts]
f1(), f1(function(x) {
return str(x);
}), f1(function(x) {
return num(x);
}, function(x) {
return str(x);
}), f1(function(x) {
return num(x);
}, function(x) {
return num(x);
}, function(x) {
return str(x);
});
export function createSelector() {
for(var _len = arguments.length, selectors = Array(_len), _key = 0; _key < _len; _key++)selectors[_key] = arguments[_key];
console.log(selectors);
}
createSelector(function(x) {
return x.foo;
}, function(x) {
return x.bar;
}, function() {
return 42;
}), example(function(x) {
return x.foo;
}, function(x) {
return x.bar;
}, function(x) {
return x.baz;
}), test(function(a) {
return a;
}, function(b) {
return b;
}, function(c) {
return c;
});
11 changes: 11 additions & 0 deletions crates/swc/tests/tsc-references/es2022IntlAPIs.1.normal.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,14 @@ for (const zoneName of timezoneNames){
timeZoneName: zoneName
});
}
const enumerationKeys = [
'calendar',
'collation',
'currency',
'numberingSystem',
'timeZone',
'unit'
];
for (const key of enumerationKeys){
var supported = Intl.supportedValuesOf(key);
}
8 changes: 8 additions & 0 deletions crates/swc/tests/tsc-references/es2022IntlAPIs.2.minified.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,11 @@ for (const zoneName of [
timeZone: 'America/Los_Angeles',
timeZoneName: zoneName
});
for (const key of [
'calendar',
'collation',
'currency',
'numberingSystem',
'timeZone',
'unit'
])Intl.supportedValuesOf(key);
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//// [usage.ts]
import { Something } from "./prelude";
export var myValue = Something.of("abc");
//// [Something.ts]
export { };
//// [prelude.ts]
import * as _Something from "./Something";
export { _Something as Something };
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//// [usage.ts]
import { Something } from "./prelude";
export var myValue = Something.of("abc");
//// [Something.ts]
export { };
//// [prelude.ts]
import * as _Something from "./Something";
export { _Something as Something };
70 changes: 70 additions & 0 deletions crates/swc/tests/tsc-references/extendsTag5.1.normal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
//// [/a.js]
/**
* @typedef {{
* a: number | string;
* b: boolean | string[];
* }} Foo
*/ /**
* @template {Foo} T
*/ import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
import { _ as _inherits } from "@swc/helpers/_/_inherits";
import { _ as _create_super } from "@swc/helpers/_/_create_super";
var A = function A(a) {
"use strict";
_class_call_check(this, A);
return a;
};
/**
* @extends {A<{
* a: string,
* b: string[]
* }>}
*/ var B = /*#__PURE__*/ function(A) {
"use strict";
_inherits(B, A);
var _super = _create_super(B);
function B() {
_class_call_check(this, B);
return _super.apply(this, arguments);
}
return B;
}(A);
/**
* @extends {A<{
* a: string,
* b: string
* }>}
*/ var C = /*#__PURE__*/ function(A) {
"use strict";
_inherits(C, A);
var _super = _create_super(C);
function C() {
_class_call_check(this, C);
return _super.apply(this, arguments);
}
return C;
}(A);
/**
* @extends {A<{a: string, b: string[]}>}
*/ var D = /*#__PURE__*/ function(A) {
"use strict";
_inherits(D, A);
var _super = _create_super(D);
function D() {
_class_call_check(this, D);
return _super.apply(this, arguments);
}
return D;
}(A);
/**
* @extends {A<{a: string, b: string}>}
*/ var E = /*#__PURE__*/ function(A) {
"use strict";
_inherits(E, A);
var _super = _create_super(E);
function E() {
_class_call_check(this, E);
return _super.apply(this, arguments);
}
return E;
}(A);
Loading

1 comment on commit 603f22d

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 603f22d Previous: 577f81e Ratio
es/full/bugs-1 301967 ns/iter (± 8460) 298983 ns/iter (± 13936) 1.01
es/full/minify/libraries/antd 1531881621 ns/iter (± 22040620) 1547551128 ns/iter (± 21711343) 0.99
es/full/minify/libraries/d3 294315914 ns/iter (± 12230859) 294247426 ns/iter (± 14248468) 1.00
es/full/minify/libraries/echarts 1221420565 ns/iter (± 21209379) 1186462242 ns/iter (± 30465419) 1.03
es/full/minify/libraries/jquery 90773566 ns/iter (± 1027713) 90737149 ns/iter (± 1000954) 1.00
es/full/minify/libraries/lodash 105612807 ns/iter (± 688691) 104932341 ns/iter (± 1069936) 1.01
es/full/minify/libraries/moment 52128660 ns/iter (± 264033) 52215407 ns/iter (± 1210417) 1.00
es/full/minify/libraries/react 18903366 ns/iter (± 136787) 19177403 ns/iter (± 221925) 0.99
es/full/minify/libraries/terser 239821419 ns/iter (± 4877165) 240715459 ns/iter (± 3639104) 1.00
es/full/minify/libraries/three 427677525 ns/iter (± 13128437) 425957653 ns/iter (± 7627247) 1.00
es/full/minify/libraries/typescript 2921791482 ns/iter (± 17760202) 2925690377 ns/iter (± 29457031) 1.00
es/full/minify/libraries/victory 669305732 ns/iter (± 17268649) 641826585 ns/iter (± 12141999) 1.04
es/full/minify/libraries/vue 130951297 ns/iter (± 2951745) 129122406 ns/iter (± 1209971) 1.01
es/full/codegen/es3 28288 ns/iter (± 76) 28543 ns/iter (± 503) 0.99
es/full/codegen/es5 28384 ns/iter (± 102) 28569 ns/iter (± 53) 0.99
es/full/codegen/es2015 28347 ns/iter (± 74) 28583 ns/iter (± 134) 0.99
es/full/codegen/es2016 28322 ns/iter (± 96) 28570 ns/iter (± 64) 0.99
es/full/codegen/es2017 28329 ns/iter (± 64) 28597 ns/iter (± 42) 0.99
es/full/codegen/es2018 28288 ns/iter (± 66) 28538 ns/iter (± 84) 0.99
es/full/codegen/es2019 28414 ns/iter (± 67) 28572 ns/iter (± 63) 0.99
es/full/codegen/es2020 28384 ns/iter (± 61) 28570 ns/iter (± 121) 0.99
es/full/all/es3 179117989 ns/iter (± 2969074) 181312398 ns/iter (± 3273099) 0.99
es/full/all/es5 171742708 ns/iter (± 1667105) 172889094 ns/iter (± 1478819) 0.99
es/full/all/es2015 132353818 ns/iter (± 1132207) 132291989 ns/iter (± 1732927) 1.00
es/full/all/es2016 130280825 ns/iter (± 1895236) 131326943 ns/iter (± 1383088) 0.99
es/full/all/es2017 128278586 ns/iter (± 2201368) 128751199 ns/iter (± 1932390) 1.00
es/full/all/es2018 124115818 ns/iter (± 1121195) 125832962 ns/iter (± 1709115) 0.99
es/full/all/es2019 123085629 ns/iter (± 1855474) 122797541 ns/iter (± 1526521) 1.00
es/full/all/es2020 116966618 ns/iter (± 924346) 117824261 ns/iter (± 1345075) 0.99
es/full/parser 507914 ns/iter (± 7099) 508968 ns/iter (± 6868) 1.00
es/full/base/fixer 22409 ns/iter (± 71) 22643 ns/iter (± 26) 0.99
es/full/base/resolver_and_hygiene 85683 ns/iter (± 122) 87933 ns/iter (± 74) 0.97
serialization of serde 121 ns/iter (± 0) 121 ns/iter (± 0) 1
css/minify/libraries/bootstrap 27454425 ns/iter (± 227006) 27659258 ns/iter (± 100260) 0.99
css/visitor/compare/clone 2128958 ns/iter (± 16633) 2134688 ns/iter (± 6005) 1.00
css/visitor/compare/visit_mut_span 2308411 ns/iter (± 5107) 2286812 ns/iter (± 9777) 1.01
css/visitor/compare/visit_mut_span_panic 2378296 ns/iter (± 6475) 2333647 ns/iter (± 6462) 1.02
css/visitor/compare/fold_span 3091177 ns/iter (± 20664) 3069323 ns/iter (± 19735) 1.01
css/visitor/compare/fold_span_panic 3243326 ns/iter (± 12628) 3228820 ns/iter (± 10816) 1.00
css/lexer/bootstrap_5_1_3 5174744 ns/iter (± 28138) 5179174 ns/iter (± 15600) 1.00
css/lexer/foundation_6_7_4 4336804 ns/iter (± 2616) 4358110 ns/iter (± 3257) 1.00
css/lexer/tailwind_3_1_1 823071 ns/iter (± 946) 827428 ns/iter (± 1140) 0.99
css/parser/bootstrap_5_1_3 21200474 ns/iter (± 206689) 20827921 ns/iter (± 198652) 1.02
css/parser/foundation_6_7_4 16809071 ns/iter (± 30555) 16615141 ns/iter (± 64983) 1.01
css/parser/tailwind_3_1_1 3234533 ns/iter (± 3091) 3211951 ns/iter (± 4920) 1.01
es/codegen/colors 320244 ns/iter (± 181653) 325583 ns/iter (± 184816) 0.98
es/codegen/large 1241692 ns/iter (± 649476) 1250660 ns/iter (± 646650) 0.99
es/codegen/with-parser/colors 47319 ns/iter (± 318) 47018 ns/iter (± 115) 1.01
es/codegen/with-parser/large 510374 ns/iter (± 1122) 506703 ns/iter (± 1200) 1.01
es/minify/libraries/antd 1331665703 ns/iter (± 17541072) 1340286134 ns/iter (± 16685987) 0.99
es/minify/libraries/d3 249948444 ns/iter (± 4538635) 249929680 ns/iter (± 5055993) 1.00
es/minify/libraries/echarts 1035250695 ns/iter (± 18580728) 1034521237 ns/iter (± 37383615) 1.00
es/minify/libraries/jquery 78713323 ns/iter (± 912302) 79795260 ns/iter (± 1118357) 0.99
es/minify/libraries/lodash 95691864 ns/iter (± 1673212) 95486819 ns/iter (± 1332321) 1.00
es/minify/libraries/moment 45341932 ns/iter (± 487691) 45576917 ns/iter (± 521101) 0.99
es/minify/libraries/react 16987892 ns/iter (± 142481) 17045960 ns/iter (± 152495) 1.00
es/minify/libraries/terser 204729775 ns/iter (± 3054303) 205907701 ns/iter (± 6836831) 0.99
es/minify/libraries/three 354500849 ns/iter (± 6833598) 364804431 ns/iter (± 9097477) 0.97
es/minify/libraries/typescript 2506822632 ns/iter (± 21532232) 2507621727 ns/iter (± 22876742) 1.00
es/minify/libraries/victory 560963651 ns/iter (± 19889160) 551192739 ns/iter (± 14811206) 1.02
es/minify/libraries/vue 115377188 ns/iter (± 1245239) 115120280 ns/iter (± 2407344) 1.00
es/visitor/compare/clone 2343666 ns/iter (± 14853) 2308004 ns/iter (± 11593) 1.02
es/visitor/compare/visit_mut_span 2704455 ns/iter (± 3928) 2715254 ns/iter (± 6967) 1.00
es/visitor/compare/visit_mut_span_panic 2737291 ns/iter (± 3729) 2749092 ns/iter (± 12778) 1.00
es/visitor/compare/fold_span 3817859 ns/iter (± 5672) 3815535 ns/iter (± 4826) 1.00
es/visitor/compare/fold_span_panic 3932391 ns/iter (± 7310) 3947230 ns/iter (± 16000) 1.00
es/lexer/colors 13268 ns/iter (± 11) 13207 ns/iter (± 7) 1.00
es/lexer/angular 6416232 ns/iter (± 6245) 6425559 ns/iter (± 7407) 1.00
es/lexer/backbone 794229 ns/iter (± 881) 793392 ns/iter (± 470) 1.00
es/lexer/jquery 4447003 ns/iter (± 4577) 4455130 ns/iter (± 5842) 1.00
es/lexer/jquery mobile 6951170 ns/iter (± 4029) 6946206 ns/iter (± 4132) 1.00
es/lexer/mootools 3487150 ns/iter (± 3029) 3478974 ns/iter (± 2383) 1.00
es/lexer/underscore 654517 ns/iter (± 929) 654352 ns/iter (± 998) 1.00
es/lexer/three 21083000 ns/iter (± 41081) 20933337 ns/iter (± 31774) 1.01
es/lexer/yui 3896415 ns/iter (± 4554) 3880086 ns/iter (± 3424) 1.00
es/parser/colors 28978 ns/iter (± 27) 28870 ns/iter (± 62) 1.00
es/parser/angular 14907462 ns/iter (± 126272) 14977212 ns/iter (± 153738) 1.00
es/parser/backbone 2134368 ns/iter (± 10841) 2176491 ns/iter (± 12337) 0.98
es/parser/jquery 11673365 ns/iter (± 85541) 11773064 ns/iter (± 104772) 0.99
es/parser/jquery mobile 18422368 ns/iter (± 193171) 18307940 ns/iter (± 219958) 1.01
es/parser/mootools 8876963 ns/iter (± 38505) 8983330 ns/iter (± 36871) 0.99
es/parser/underscore 1809893 ns/iter (± 12301) 1829299 ns/iter (± 11647) 0.99
es/parser/three 52416671 ns/iter (± 578466) 53294371 ns/iter (± 223514) 0.98
es/parser/yui 8967823 ns/iter (± 42561) 9070565 ns/iter (± 99375) 0.99
es/preset-env/usage/builtin_type 143725 ns/iter (± 35492) 144152 ns/iter (± 36068) 1.00
es/preset-env/usage/property 19619 ns/iter (± 70) 19623 ns/iter (± 126) 1.00
es/resolver/typescript 110424811 ns/iter (± 2245232) 109498443 ns/iter (± 2064699) 1.01
es/fixer/typescript 76873218 ns/iter (± 819361) 78318336 ns/iter (± 430810) 0.98
es/hygiene/typescript 165157796 ns/iter (± 2487219) 167910079 ns/iter (± 1664295) 0.98
es/resolver_with_hygiene/typescript 310312512 ns/iter (± 4308333) 305079780 ns/iter (± 3466630) 1.02
es/visitor/base-perf/module_clone 81396 ns/iter (± 406) 81133 ns/iter (± 404) 1.00
es/visitor/base-perf/fold_empty 91504 ns/iter (± 330) 90554 ns/iter (± 1658) 1.01
es/visitor/base-perf/fold_noop_impl_all 91403 ns/iter (± 434) 90680 ns/iter (± 398) 1.01
es/visitor/base-perf/fold_noop_impl_vec 91690 ns/iter (± 421) 91270 ns/iter (± 349) 1.00
es/visitor/base-perf/boxing_boxed_clone 56 ns/iter (± 0) 58 ns/iter (± 0) 0.97
es/visitor/base-perf/boxing_unboxed_clone 41 ns/iter (± 0) 41 ns/iter (± 0) 1
es/visitor/base-perf/boxing_boxed 103 ns/iter (± 0) 109 ns/iter (± 0) 0.94
es/visitor/base-perf/boxing_unboxed 79 ns/iter (± 0) 79 ns/iter (± 0) 1
es/visitor/base-perf/visit_contains_this 3387 ns/iter (± 63) 3588 ns/iter (± 88) 0.94
es/base/parallel/resolver/typescript 6118463329 ns/iter (± 465050565) 6173373655 ns/iter (± 384900029) 0.99
es/base/parallel/hygiene/typescript 1984466757 ns/iter (± 26801439) 1993401115 ns/iter (± 37776244) 1.00
misc/visitors/time-complexity/time 5 106 ns/iter (± 0) 101 ns/iter (± 0) 1.05
misc/visitors/time-complexity/time 10 340 ns/iter (± 0) 338 ns/iter (± 7) 1.01
misc/visitors/time-complexity/time 15 664 ns/iter (± 0) 643 ns/iter (± 1) 1.03
misc/visitors/time-complexity/time 20 1227 ns/iter (± 5) 1196 ns/iter (± 18) 1.03
misc/visitors/time-complexity/time 40 6220 ns/iter (± 11) 6525 ns/iter (± 72) 0.95
misc/visitors/time-complexity/time 60 15604 ns/iter (± 18) 17281 ns/iter (± 51) 0.90
es/full-target/es2016 253472 ns/iter (± 617) 253316 ns/iter (± 535) 1.00
es/full-target/es2017 246086 ns/iter (± 418) 245757 ns/iter (± 487) 1.00
es/full-target/es2018 235673 ns/iter (± 543) 235703 ns/iter (± 558) 1.00
es2020_nullish_coalescing 92878 ns/iter (± 285) 93423 ns/iter (± 379) 0.99
es2020_optional_chaining 124202 ns/iter (± 291) 124239 ns/iter (± 317) 1.00
es2022_class_properties 149104 ns/iter (± 161) 149967 ns/iter (± 344) 0.99
es2018_object_rest_spread 96132 ns/iter (± 1046) 96332 ns/iter (± 221) 1.00
es2019_optional_catch_binding 85273 ns/iter (± 208) 85528 ns/iter (± 180) 1.00
es2017_async_to_generator 85789 ns/iter (± 202) 86254 ns/iter (± 274) 0.99
es2016_exponentiation 90507 ns/iter (± 291) 91224 ns/iter (± 271) 0.99
es2015_arrow 93889 ns/iter (± 275) 94030 ns/iter (± 294) 1.00
es2015_block_scoped_fn 91303 ns/iter (± 178) 92537 ns/iter (± 165) 0.99
es2015_block_scoping 169533 ns/iter (± 335) 170503 ns/iter (± 246) 0.99

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

Please sign in to comment.