Merge pull request 'fix(workflow): resolve type errors across all packages' (#16) from fix/type-errors-and-tsbuildinfo into main
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { type ChildProcessWithoutNullStreams, spawn } from "node:child_process";
|
||||
import { type ChildProcess, spawn } from "node:child_process";
|
||||
import { mkdir, readdir, unlink, writeFile } from "node:fs/promises";
|
||||
import { createConnection } from "node:net";
|
||||
import { join } from "node:path";
|
||||
@@ -23,7 +23,7 @@ function isProcessAlive(pid: number): boolean {
|
||||
|
||||
async function waitForReadyLine(
|
||||
childStdout: NodeJS.ReadableStream,
|
||||
child: ChildProcessWithoutNullStreams,
|
||||
child: ChildProcess,
|
||||
): Promise<Result<number, string>> {
|
||||
return await new Promise((resolve) => {
|
||||
let buf = "";
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
"sourceMap": true,
|
||||
"composite": true,
|
||||
"outDir": "dist",
|
||||
"rootDir": "src"
|
||||
"rootDir": "src",
|
||||
"types": ["bun-types"]
|
||||
},
|
||||
"references": [{ "path": "../workflow" }],
|
||||
"include": ["src/**/*.ts"]
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -12,5 +12,8 @@
|
||||
"@uncaged/workflow": "workspace:*",
|
||||
"@uncaged/workflow-util-role": "workspace:*",
|
||||
"zod": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^25.6.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
"compilerOptions": {
|
||||
"rootDir": "src",
|
||||
"outDir": "dist",
|
||||
"composite": true
|
||||
"composite": true,
|
||||
"types": ["bun-types"]
|
||||
},
|
||||
"include": ["src/**/*.ts"],
|
||||
"references": [{ "path": "../workflow" }, { "path": "../workflow-util-role" }]
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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
Reference in New Issue
Block a user