Skip to content

Commit 309a477

Browse files
committed
fix(typecheck): make compiler dependencies visible to Knip
1 parent 039a183 commit 309a477

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

‎knip.jsonc‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
},
1919
"scripts": {
2020
// Knip loads its preprocessor through a CLI option; native verification and
21-
// worktree setup (from t3.json) run directly.
22-
"entry": ["knip-schemas.ts", "mobile-native-client.ts", "setup-worktree.ts"],
21+
// worktree setup (from t3.json), and the shared typecheck launcher run directly.
22+
"entry": ["knip-schemas.ts", "mobile-native-client.ts", "setup-worktree.ts", "typecheck.ts"],
2323
},
2424
"apps/server": {
2525
// Vite+ pack entries and the launcher used by installed background services.

‎scripts/typecheck.ts‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import * as Effect from "effect/Effect";
88
import * as NodeChildProcess from "node:child_process";
99
import * as NodeURL from "node:url";
1010

11-
function runCompiler(relativePath: string, args: ReadonlyArray<string>) {
11+
function runCompiler(compilerUrl: URL, args: ReadonlyArray<string>) {
1212
const result = NodeChildProcess.spawnSync(
1313
process.execPath,
14-
[NodeURL.fileURLToPath(new URL(relativePath, import.meta.url)), ...args],
14+
[NodeURL.fileURLToPath(compilerUrl), ...args],
1515
{ stdio: "inherit" },
1616
);
1717
if (result.error) throw result.error;
@@ -27,12 +27,18 @@ const supportsRust =
2727
(platform === "linux" && architecture === "x64");
2828

2929
if (supportsRust && extraArgs.length === 0) {
30-
process.exitCode = runCompiler("../node_modules/tsc-rs/bin/tsc-rs", ["--noEmit"]);
30+
process.exitCode = runCompiler(
31+
new URL("./bin/tsc-rs", import.meta.resolve("tsc-rs/package.json")),
32+
["--noEmit"],
33+
);
3134
} else {
3235
process.stderr.write(
3336
supportsRust
3437
? "Custom compiler arguments use Effect-patched TypeScript.\n"
3538
: `tsc-rs has no ${platform}-${architecture} binary; using Effect-patched TypeScript.\n`,
3639
);
37-
process.exitCode = runCompiler("../node_modules/typescript/bin/tsc", ["--noEmit", ...extraArgs]);
40+
process.exitCode = runCompiler(
41+
new URL("./bin/tsc", import.meta.resolve("typescript/package.json")),
42+
["--noEmit", ...extraArgs],
43+
);
3844
}

0 commit comments

Comments
 (0)