Skip to content

Commit af03394

Browse files
committed
fix typechecks
1 parent 157dde9 commit af03394

File tree

3 files changed

+53
-2
lines changed

3 files changed

+53
-2
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"version": "0.0.0",
44
"description": "an api for computers",
55
"scripts": {
6-
"check": "biome check && tsc --noEmit",
6+
"typecheck": "tsx scripts/typecheck.ts",
7+
"check": "biome check && npm run typecheck",
78
"build": "npm run build -w @cloudflare/sandbox",
89
"test": "echo 'No tests'",
910
"toc": "doctoc README.md --github --maxlevel 3 && node scripts/fix-toc-links.js"

scripts/typecheck.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { type ExecException, execSync } from "node:child_process";
2+
import fg from "fast-glob";
3+
4+
const tsconfigs: string[] = [];
5+
6+
for await (const file of await fg.glob("**/tsconfig.json")) {
7+
if (file.includes("node_modules")) continue;
8+
tsconfigs.push(file);
9+
}
10+
11+
console.log(`Typechecking ${tsconfigs.length} projects...`);
12+
13+
type Result = {
14+
tsconfig: string;
15+
success: boolean;
16+
output: string;
17+
};
18+
19+
const results: Result[] = [];
20+
21+
for (const tsconfig of tsconfigs) {
22+
console.log(`Checking ${tsconfig}...`);
23+
try {
24+
const output = execSync(`tsc -p ${tsconfig}`, {
25+
encoding: "utf-8",
26+
stdio: ["pipe", "pipe", "pipe"],
27+
});
28+
results.push({ tsconfig, success: true, output });
29+
console.log(`✅ ${tsconfig} - OK`);
30+
} catch (rawError: unknown) {
31+
const error = rawError as ExecException;
32+
33+
const output =
34+
error.stdout?.toString() || `${error.stderr?.toString()}` || "";
35+
results.push({ tsconfig, success: false, output });
36+
console.error(`❌ ${tsconfig} - Failed:`);
37+
console.error(output);
38+
}
39+
}
40+
41+
const failed = results.filter((r) => !r.success);
42+
43+
if (failed.length > 0) {
44+
console.error(
45+
`\n${failed.length} of ${tsconfigs.length} projects failed to typecheck!`
46+
);
47+
process.exit(1);
48+
}
49+
50+
console.log("All projects typecheck successfully!");

tsconfig.base.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
6565
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
6666
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
67-
// "noEmit": true, /* Disable emitting files from a compilation. */
67+
"noEmit": true /* Disable emitting files from a compilation. */,
6868
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
6969
// "outDir": "./", /* Specify an output folder for all emitted files. */
7070
// "removeComments": true, /* Disable emitting comments. */

0 commit comments

Comments
 (0)