fix(workflow): resolve type errors across all packages and remove tsbuildinfo from tracking

- Add bun-types and @types/xxhashjs to root devDependencies
- Add types: ['bun-types'] to root and package tsconfigs
- Fix AST Node type narrowing in bundle-validator.ts with AcornNode type and narrowNode helper
- Fix generic ThreadContext variance in create-role-moderator.ts
- Add explicit parameter types in worker.ts
- Fix ChildProcess type in worker-spawn.ts to match spawn() stdio config
- Remove all tsconfig.tsbuildinfo from git tracking
- Add tsconfig.tsbuildinfo to .gitignore
This commit is contained in:
2026-05-06 17:34:12 +08:00
parent c04e7c31af
commit 98b6153070
20 changed files with 38 additions and 26 deletions
+18 -7
View File
@@ -10,6 +10,17 @@ import type {
Program,
VariableDeclaration,
} from "acorn";
/** Acorn Node with index-access for property traversal. */
type AcornNode = Node & { [key: string]: unknown };
/**
* Narrow an Acorn Node to a specific AST subtype after a `.type` guard.
* Avoids double-cast (`as unknown as T`) by going through AcornNode.
*/
function narrowNode<T extends Node>(node: Node): T {
return node as unknown as T;
}
import * as acorn from "acorn";
import { err, ok, type Result } from "./result.js";
@@ -55,7 +66,7 @@ function pushNestedAstNodes(value: unknown, out: Node[]): void {
function collectChildNodes(node: Node): Node[] {
const children: Node[] = [];
for (const key of Object.keys(node)) {
const val = (node as Record<string, unknown>)[key];
const val = (node as AcornNode)[key];
pushNestedAstNodes(val, children);
}
return children;
@@ -273,10 +284,10 @@ function descriptorExportExists(program: Program): boolean {
}
function stringLiteralModuleSpecifier(src: Node): string | null {
if (src.type !== "Literal" || typeof src.value !== "string") {
if (src.type !== "Literal" || typeof (src as AcornNode).value !== "string") {
return null;
}
return src.value;
return (src as AcornNode).value as string;
}
function validateImportDeclaration(node: ImportDeclaration): string | null {
@@ -337,16 +348,16 @@ function bundleConstraintViolationForNode(node: Node): string | null {
return "dynamic import() is not allowed in workflow bundles";
}
if (node.type === "ImportDeclaration") {
return validateImportDeclaration(node);
return validateImportDeclaration(narrowNode<ImportDeclaration>(node));
}
if (node.type === "ExportNamedDeclaration") {
return validateExportNamedDeclaration(node);
return validateExportNamedDeclaration(narrowNode<ExportNamedDeclaration>(node));
}
if (node.type === "ExportAllDeclaration") {
return validateExportAllDeclaration(node);
return validateExportAllDeclaration(narrowNode<ExportAllDeclaration>(node));
}
if (node.type === "CallExpression") {
return validateRequireCall(node);
return validateRequireCall(narrowNode<CallExpression>(node));
}
return null;
}
@@ -69,7 +69,7 @@ export function createRoleModerator<M extends RoleMeta>(
return { returnCode: 1, summary: `unknown role: ${next}` };
}
const result = await roleFn(ctx);
const result = await roleFn(ctx as unknown as ThreadContext);
const ts = Date.now();
const step = {
role: next,
+2 -2
View File
@@ -423,7 +423,7 @@ async function main(): Promise<void> {
});
}
const server = createServer((socket) => {
const server = createServer((socket: Socket) => {
void (async () => {
const line = await readLineFromSocket(socket);
if (line === null) {
@@ -439,7 +439,7 @@ async function main(): Promise<void> {
})();
});
server.on("error", (errObj) => {
server.on("error", (errObj: Error) => {
bootLog("W8YK4NPX", `worker server error: ${errObj.message}`);
process.exit(1);
});
+2 -1
View File
@@ -14,7 +14,8 @@
"sourceMap": true,
"composite": true,
"outDir": "dist",
"rootDir": "src"
"rootDir": "src",
"types": ["bun-types"]
},
"include": ["src/**/*.ts", "xxhashjs.d.ts"]
}
File diff suppressed because one or more lines are too long