From 2d903aae873cedda9cf1a30ac027f77f88bd7492 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Fri, 6 Dec 2024 12:23:31 -0800 Subject: [PATCH] fix return type for async wrapper functions --- src/api/js/scripts/make-ts-wrapper.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/api/js/scripts/make-ts-wrapper.ts b/src/api/js/scripts/make-ts-wrapper.ts index 568609467..6eb81c806 100644 --- a/src/api/js/scripts/make-ts-wrapper.ts +++ b/src/api/js/scripts/make-ts-wrapper.ts @@ -339,8 +339,10 @@ function makeTsWrapper() { `.trim(); } + // async functions are invocations of the wrapper from make-ts-wrapper.ts + // the wrapper spawns a thread and returns void, so we need to use void as the return type here // prettier-ignore - let invocation = `Mod.ccall('${isAsync ? "async_" : ""}${fn.name}', '${cReturnType}', ${JSON.stringify(ctypes)}, [${args.map(toEm).join(", ")}])`; + let invocation = `Mod.ccall('${isAsync ? "async_" : ""}${fn.name}', '${isAsync ? 'void' : cReturnType}', ${JSON.stringify(ctypes)}, [${args.map(toEm).join(", ")}])`; if (isAsync) { invocation = `await Mod.async_call(() => ${invocation})`;