Skip to content

Build your personal knowledge base with Trilium Notes

chore(scripts): integrate filter-tsc-output from standalone branch

Elian Doran287be0bd251d
diff --git a/package.json b/package.json
index 89a38553a6..3fd71ed2c6 100644
--- a/package.json
+++ b/package.json
@@ -36,7 +36,7 @@
"test:all": "pnpm test:parallel && pnpm test:sequential",
"test:parallel": "pnpm --filter=!server --filter=!ckeditor5-mermaid --filter=!ckeditor5-math --parallel test",
"test:sequential": "pnpm --filter=server --filter=ckeditor5-mermaid --filter=ckeditor5-math --sequential test",
- "typecheck": "tsc --build",
+ "typecheck": "tsx scripts/filter-tsc-output.mts",
"dev:format-check": "eslint -c eslint.format.config.mjs .",
"dev:format-fix": "eslint -c eslint.format.config.mjs . --fix",
"dev:linter-check": "cross-env NODE_OPTIONS=--max_old_space_size=4096 eslint .",
diff --git a/scripts/filter-tsc-output.mts b/scripts/filter-tsc-output.mts
new file mode 100644
index 0000000000..4652a55873
--- /dev/null
+++ b/scripts/filter-tsc-output.mts
@@ -0,0 +1,56 @@
+/**
+ * Runs `tsc --build` and filters out noisy cascade errors (TS6305).
+ * Numbers each remaining error and prints a summary at the end.
+ */
+
+import { execSync } from "child_process";
+
+const SUPPRESSED_CODES = [ "TS6305" ];
+const ERROR_LINE_PATTERN = /^.+\(\d+,\d+\): error TS\d+:/;
+
+let output: string;
+try {
+ output = execSync("tsc --build", {
+ encoding: "utf-8",
+ stdio: [ "inherit", "pipe", "pipe" ]
+ });
+} catch (err: unknown) {
+ const execErr = err as { stdout?: string; stderr?: string };
+ output = (execErr.stdout ?? "") + (execErr.stderr ?? "");
+}
+
+const lines = output.split(/\r?\n/);
+const filtered = lines.filter(
+ (line) => !SUPPRESSED_CODES.some((code) => line.includes(code))
+);
+
+let errorIndex = 0;
+const numbered: string[] = [];
+const seen = new Set<string>();
+let skipContinuation = false;
+
+for (const line of filtered) {
+ if (ERROR_LINE_PATTERN.test(line)) {
+ if (seen.has(line)) {
+ skipContinuation = true;
+ continue;
+ }
+ seen.add(line);
+ skipContinuation = false;
+ errorIndex++;
+ numbered.push(`[${errorIndex}] ${line}`);
+ } else if (line.trim()) {
+ // Continuation line (indented context for multi-line errors)
+ if (!skipContinuation) {
+ numbered.push(line);
+ }
+ }
+}
+
+if (errorIndex > 0) {
+ console.log(numbered.join("\n"));
+ console.log(`\n${errorIndex} error(s) found.`);
+ process.exit(1);
+} else {
+ console.log("No errors found.");
+}