Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

typecheck: include scripts/ (F3)

garrytanddcd2a49cf1f
diff --git a/scripts/check-engine-dynamic-import.ts b/scripts/check-engine-dynamic-import.ts
index da658f4b26..e3eebde3c8 100644
--- a/scripts/check-engine-dynamic-import.ts
+++ b/scripts/check-engine-dynamic-import.ts
@@ -3,6 +3,9 @@
import { readFile } from 'node:fs/promises';
import ts from 'typescript';
+/** `ts.getTokenAtPosition` is exported at runtime but absent from typescript's public declarations. */
+const tsInternal = ts as typeof ts & { getTokenAtPosition(sourceFile: ts.SourceFile, position: number): ts.Node };
+
const MARKER = 'engine-dynamic-import-ok';
const MARKER_TOKEN_CHAR = /[\p{ID_Continue}$-]/u;
const files = process.argv.slice(2);
@@ -29,8 +32,9 @@ for (const file of files) {
const lines = sourceText.split(/\r?\n/);
const markerLines = new Set<number>();
- if (sourceFile.parseDiagnostics.length > 0) {
- const diagnostics = sourceFile.parseDiagnostics
+ const { parseDiagnostics } = sourceFile as ts.SourceFile & { parseDiagnostics: readonly ts.Diagnostic[] };
+ if (parseDiagnostics.length > 0) {
+ const diagnostics = parseDiagnostics
.map((diagnostic) => ts.flattenDiagnosticMessageText(diagnostic.messageText, ' '))
.join('; ');
readErrors.push(`ERROR: cannot parse input file ${file}: ${diagnostics}`);
@@ -41,7 +45,7 @@ for (const file of files) {
const after = Array.from(sourceText.slice(markerPos + MARKER.length))[0];
const standaloneMarker = (!before || !MARKER_TOKEN_CHAR.test(before))
&& (!after || !MARKER_TOKEN_CHAR.test(after));
- const token = ts.getTokenAtPosition(sourceFile, markerPos);
+ const token = tsInternal.getTokenAtPosition(sourceFile, markerPos);
const insideToken = token.getStart(sourceFile) <= markerPos && markerPos < token.end;
if (standaloneMarker && !insideToken) {
markerLines.add(sourceFile.getLineAndCharacterOfPosition(markerPos).line);
diff --git a/scripts/check-engine-sql-ratchet.ts b/scripts/check-engine-sql-ratchet.ts
index 6d6cd21dc4..5566bf3fe8 100644
--- a/scripts/check-engine-sql-ratchet.ts
+++ b/scripts/check-engine-sql-ratchet.ts
@@ -45,6 +45,9 @@ import { existsSync, readdirSync, readFileSync, statSync, writeFileSync } from '
import { join, relative } from 'node:path';
import ts from 'typescript';
+/** `ts.getTokenAtPosition` is exported at runtime but absent from typescript's public declarations. */
+const tsInternal = ts as typeof ts & { getTokenAtPosition(sourceFile: ts.SourceFile, position: number): ts.Node };
+
const ROOT = process.env.GBRAIN_GUARD_ROOT ?? join(import.meta.dir, '..');
const BASELINE_REL = 'scripts/engine-sql-baseline.tsv';
const ANCHOR = 'docs/TESTING.md#engine-sql-ratchet';
@@ -151,7 +154,7 @@ function markers(sf: ts.SourceFile): Map<number, string> {
const out = new Map<number, string>();
const re = new RegExp(String.raw`//\s*${MARKER}\b(:?)([^\n]*)`, 'g');
for (let m = re.exec(text); m; m = re.exec(text)) {
- const token = ts.getTokenAtPosition(sf, m.index);
+ const token = tsInternal.getTokenAtPosition(sf, m.index);
if (token.getStart(sf) <= m.index && m.index < token.end) continue;
out.set(sf.getLineAndCharacterOfPosition(m.index).line + 1, m[1] ? m[2].trim() : '');
}
diff --git a/scripts/dx-explore.ts b/scripts/dx-explore.ts
index 5c2bb4ecd3..7b883f5878 100644
--- a/scripts/dx-explore.ts
+++ b/scripts/dx-explore.ts
@@ -216,7 +216,7 @@ interface ScenarioCtx {
* transcripts, the live screen mirror, events.jsonl. Structural, not
* checklist: writes go through redactSecrets at the write site. */
redact: Record<string, string>;
- events: Array<{ tMs: number; kind: 'input' | 'note' | 'screen'; data: string }>;
+ events: Array<{ tMs: number; kind: 'input' | 'note' | 'screen' | 'friction'; data: string }>;
t0: number;
}
@@ -256,7 +256,7 @@ function tmp(ctx: ScenarioCtx, prefix: string): string {
return dir;
}
-function event(ctx: ScenarioCtx, kind: 'input' | 'note' | 'screen', data: string): void {
+function event(ctx: ScenarioCtx, kind: 'input' | 'note' | 'screen' | 'friction', data: string): void {
ctx.events.push({ tMs: Date.now() - ctx.t0, kind, data });
}
diff --git a/scripts/image-decoders-smoketest.ts b/scripts/image-decoders-smoketest.ts
index bd7e758112..d1f91b812d 100644
--- a/scripts/image-decoders-smoketest.ts
+++ b/scripts/image-decoders-smoketest.ts
@@ -58,7 +58,7 @@ async function decodeAvif(): Promise<DecodeResult> {
const wasmModule = await WebAssembly.compile(wasmBytes);
await initAvif(wasmModule);
const buf = readFileSync(avifFixture);
- const result = await avifDecode(buf);
+ const result = await avifDecode(new Uint8Array(buf).buffer);
if (!result || !result.data || result.data.byteLength === 0) {
return { ok: false, error: 'avif decode returned empty pixel buffer' };
}
diff --git a/scripts/image-fixture-assets.d.ts b/scripts/image-fixture-assets.d.ts
new file mode 100644
index 0000000000..2b94e67b5b
--- /dev/null
+++ b/scripts/image-fixture-assets.d.ts
@@ -0,0 +1,11 @@
+// `with { type: 'file' }` imports of the image fixtures in
+// scripts/image-decoders-smoketest.ts resolve to the embedded file's path.
+declare module '*.heic' {
+ const path: string;
+ export default path;
+}
+
+declare module '*.avif' {
+ const path: string;
+ export default path;
+}
diff --git a/tsconfig.json b/tsconfig.json
index 90fd8e24ef..c1b59c831c 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -15,5 +15,5 @@
"@/*": ["src/*"]
}
},
- "include": ["src", "test"]
+ "include": ["src", "test", "scripts"]
}