fix(scripts): harden typecheck gate against tsc launch failures

- PATH fallback reuses runnerArgs so --pretty false is preserved (keeps the line-based error parser intact)
- treat empty compiler output (tsc never launched) as a failed check instead of falling through to the "passed" branch and green-lighting CI
This commit is contained in:
Gauvino
2026-06-29 15:27:55 +02:00
parent deae5f12b2
commit 881e71ce1a

View File

@@ -161,11 +161,8 @@ function runTypeCheck(): { ok: boolean } {
const tscBin = require.resolve("typescript/bin/tsc");
execArgs = { cmd: process.execPath, args: [tscBin, ...runnerArgs] };
} catch {
// fallback to PATH tsc
execArgs = {
cmd: "tsc",
args: ["-p", "tsconfig.json", "--noEmit", ...extraArgs],
};
// fallback to PATH tsc (reuse runnerArgs so --pretty false is preserved)
execArgs = { cmd: "tsc", args: runnerArgs };
}
try {
@@ -190,7 +187,18 @@ function runTypeCheck(): { ok: boolean } {
return { ok: true };
} catch (error) {
const execError = error as { stderr?: string; stdout?: string };
const errorOutput = execError.stderr || execError.stdout || "";
const errorOutput = execError.stderr || execError.stdout;
// No compiler output = tsc never ran (e.g. binary missing). Don't let a
// launch failure fall through to the "passed" branch and green-light CI.
if (!errorOutput) {
const message = error instanceof Error ? error.message : String(error);
log(
`${colors.bold}TypeScript check failed to start${colors.reset} ${colors.gray}${message}${colors.reset}`,
colors.red,
);
return { ok: false };
}
// Filter out jellyseerr utils errors - this is a third-party git submodule
// that generates a large volume of known type errors