Skip to content

Commit 39dd4d9

Browse files
committed
Test core-js types with env types
1 parent e46b6ad commit 39dd4d9

File tree

9 files changed

+51
-83
lines changed

9 files changed

+51
-83
lines changed

tests/type-definitions/proposals/global/tsconfig.es2023.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests/type-definitions/proposals/global/tsconfig.es6.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests/type-definitions/proposals/global/tsconfig.esnext.json

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"include": ["./*.ts"]
4+
}

tests/type-definitions/proposals/pure/tsconfig.es2023.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests/type-definitions/proposals/pure/tsconfig.es6.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests/type-definitions/proposals/pure/tsconfig.esnext.json

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"include": ["./*.ts"]
4+
}

tests/type-definitions/runner.mjs

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import os from 'node:os';
2+
13
await $`tsc`;
24
await $`tsc -p tsconfig.require.json`;
35

@@ -6,71 +8,71 @@ const targets = [
68
'es2023',
79
'es6',
810
];
9-
1011
const typeScriptVersions = [
1112
'5.9',
1213
'5.8',
1314
'5.7',
1415
'5.6',
1516
// '5.5'
1617
];
18+
const envs = [
19+
null,
20+
'@types/node@24',
21+
'@types/node@20',
22+
'@types/node@18',
23+
'@types/bun@latest',
24+
];
25+
const types = [
26+
'global',
27+
'pure',
28+
];
1729

18-
const runTestsOnEnv = async function (typeScriptVersion, target, type) {
30+
const runTestsOnEnv = async function ({ typeScriptVersion, target, type, env }) {
1931
$.verbose = false;
20-
const command = `npx -p typescript@${ typeScriptVersion } tsc -p proposals/${ type }/tsconfig.${ target }.json`;
32+
const command = `npx -p typescript@${ typeScriptVersion }${ env ? ` -p ${ env }` : '' } tsc -p proposals/${ type }/tsconfig.json --target ${ target }`;
2133
echo(`$ ${ command }`);
2234
try {
23-
await $`npx -p typescript@${ typeScriptVersion } tsc -p proposals/${ type }/tsconfig.${ target }.json`.quiet();
35+
if (env) {
36+
await $`npx -p typescript@${ typeScriptVersion } -p ${ env } tsc -p proposals/${ type }/tsconfig.json --target ${ target }`.quiet();
37+
} else {
38+
await $`npx -p typescript@${ typeScriptVersion } tsc -p proposals/${ type }/tsconfig.json --target ${ target }`.quiet();
39+
}
2440
echo(chalk.green(`$ ${ command }`));
2541
} catch (error) {
2642
echo(`$ ${ chalk.red(command) }\n ${ error }`);
2743
process.exit(1);
2844
}
2945
};
3046

31-
// for (const version of typeScriptVersions) {
32-
// for (const target of targets) {
33-
// await Promise.all([
34-
// runTestsOnEnv(version, target, 'global'),
35-
// runTestsOnEnv(version, target, 'pure')
36-
// ]);
37-
// }
38-
// }
39-
// 51
40-
41-
// await Promise.all(
42-
// typeScriptVersions.flatMap(version =>
43-
// targets.flatMap(target => [
44-
// runTestsOnEnv(version, target, 'global'),
45-
// runTestsOnEnv(version, target, 'pure')
46-
// ])
47-
// )
48-
// );
49-
// 22
47+
async function runLimited(configs, limit) {
48+
let i = 0;
49+
async function worker() {
50+
while (i < configs.length) {
51+
const idx = i++;
52+
await runTestsOnEnv(configs[idx]);
53+
}
54+
}
55+
await Promise.all(Array.from({ length: limit }, worker));
56+
}
5057

51-
await Promise.all(
52-
typeScriptVersions.flatMap(version => targets.map(async target => {
53-
await runTestsOnEnv(version, target, 'global');
54-
await runTestsOnEnv(version, target, 'pure');
55-
})),
56-
);
57-
// 19
58+
const taskConfigs = [];
59+
types.forEach(type => {
60+
targets.forEach(target => {
61+
typeScriptVersions.forEach(version => {
62+
envs.forEach(env => {
63+
taskConfigs.push({ env, target, type, typeScriptVersion: version });
64+
});
65+
});
66+
});
67+
});
5868

59-
// for (const version of typeScriptVersions) {
60-
// await Promise.all(
61-
// targets.flatMap(target => [
62-
// runTestsOnEnv(version, target, 'global'),
63-
// runTestsOnEnv(version, target, 'pure')
64-
// ])
65-
// );
66-
// }
67-
// 59
69+
const numCPUs = os.cpus().length;
70+
await runLimited(taskConfigs, Math.max(numCPUs - 1, 1));
6871

6972
// await $`tsc -p proposals/global/tsconfig.esnext.json`;
7073
// await $`tsc -p proposals/global/tsconfig.es2023.json`;
7174
// await $`tsc -p proposals/global/tsconfig.es6.json`;
7275
//
7376
// await $`tsc -p proposals/pure/tsconfig.esnext.json`;
7477
// await $`tsc -p proposals/pure/tsconfig.es2023.json`;
75-
// await $`tsc -p proposals/pure/tsconfig.es6.json`;
76-
78+
// await $`tsc -p proposals/pure/tsconfig.es6.node.json`;

0 commit comments

Comments
 (0)