From a44505fab80309a0bd81e20ac16983523202d7e7 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 23 Sep 2026 12:37:10 +0200 Subject: [PATCH] Fix the koffi type friction found by the first ygg-verify pass koffi's own .d.ts resolves as an ECMAScript module under Node16 resolution, which a CommonJS `typeof import("koffi")` reference and a `koffi.promisify` property access (which does not exist) both choke on. Type the loaded module as `any` and promisify `nextEvent.async` with `node:util` directly instead of guessing at a koffi-native promise helper. Co-Authored-By: Claude Sonnet 5 --- packages/cultmesh-ts/src/realtime-quic-native.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/cultmesh-ts/src/realtime-quic-native.ts b/packages/cultmesh-ts/src/realtime-quic-native.ts index 63ffeb89..0eb1242e 100644 --- a/packages/cultmesh-ts/src/realtime-quic-native.ts +++ b/packages/cultmesh-ts/src/realtime-quic-native.ts @@ -135,8 +135,11 @@ function resolveNativeDir(): string { function loadBindings(): NativeBindings { if (bindingsCache) return bindingsCache; + // Untyped on purpose: koffi's own type declarations are ESM-flavored and + // fight a CommonJS `typeof import(...)` reference under Node16 resolution. // eslint-disable-next-line @typescript-eslint/no-var-requires - const koffi = require("koffi") as typeof import("koffi"); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const koffi: any = require("koffi"); const { bridge, dependency } = platformFileNames(); const dir = resolveNativeDir(); const bridgePath = join(dir, bridge); @@ -210,9 +213,9 @@ function loadBindings(): NativeBindings { ); const lastStatus = bridgeLib.func("int32_t cultmesh_quic_last_status(void *runtime)"); - const nextEventAsync = koffi.promisify - ? koffi.promisify(nextEvent.async) - : (require("node:util").promisify(nextEvent.async) as NativeBindings["nextEventAsync"]); + // eslint-disable-next-line @typescript-eslint/no-var-requires + const { promisify } = require("node:util") as typeof import("node:util"); + const nextEventAsync = promisify(nextEvent.async) as NativeBindings["nextEventAsync"]; bindingsCache = { runtimeOpen: (appName) => runtimeOpen(appName),