From 7580592e984c0c7ad824976e30f1c01a109e814b Mon Sep 17 00:00:00 2001 From: Andreas Opferkuch Date: Thu, 10 Apr 2025 11:44:54 +0200 Subject: [PATCH 1/3] Improve MainModuleFactory type emitted by create_tsd --- tools/emscripten.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/emscripten.py b/tools/emscripten.py index 55ffea93aa7ce..7b145421d776f 100644 --- a/tools/emscripten.py +++ b/tools/emscripten.py @@ -679,7 +679,7 @@ def create_tsd(metadata, embind_tsd): return_type = 'MainModule' if settings.WASM_ASYNC_COMPILATION: return_type = f'Promise<{return_type}>' - out += f'export default function MainModuleFactory (options?: unknown): {return_type};\n' + out += f'export default function MainModuleFactory (moduleOverrides?: Partial): {return_type};\n' return out From 9485ed56d4be327b1d2fd5fb7ec0a2252b2336b8 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 10 Apr 2025 11:29:32 -0700 Subject: [PATCH 2/3] update test expectation --- src/postamble.js | 4 ++-- test/other/embind_tsgen_ignore_2.d.ts | 2 +- test/other/embind_tsgen_module.d.ts | 2 +- test/other/test_emit_tsd.d.ts | 2 +- test/other/test_emit_tsd_sync.d.ts | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/postamble.js b/src/postamble.js index 02864dcaf146a..fba876fd58666 100644 --- a/src/postamble.js +++ b/src/postamble.js @@ -300,8 +300,8 @@ function preInit() { } #if MODULARIZE == 'instance' -export default async function init(moduleArg = {}) { - Module = moduleArg; +export default async function init(args = {}) { + moduleArgs = args; processModuleArgs(); #if WASM_ESM_INTEGRATION updateMemoryViews(); diff --git a/test/other/embind_tsgen_ignore_2.d.ts b/test/other/embind_tsgen_ignore_2.d.ts index f56a1d323f526..1899e864bb90d 100644 --- a/test/other/embind_tsgen_ignore_2.d.ts +++ b/test/other/embind_tsgen_ignore_2.d.ts @@ -151,4 +151,4 @@ interface EmbindModule { } export type MainModule = WasmModule & EmbindModule; -export default function MainModuleFactory (options?: unknown): Promise; +export default function MainModuleFactory (moduleOverrides?: Partial): Promise; diff --git a/test/other/embind_tsgen_module.d.ts b/test/other/embind_tsgen_module.d.ts index c0f947d09e3cf..56f3631ba3813 100644 --- a/test/other/embind_tsgen_module.d.ts +++ b/test/other/embind_tsgen_module.d.ts @@ -152,4 +152,4 @@ interface EmbindModule { } export type MainModule = WasmModule & EmbindModule; -export default function MainModuleFactory (options?: unknown): Promise; +export default function MainModuleFactory (moduleOverrides?: Partial): Promise; diff --git a/test/other/test_emit_tsd.d.ts b/test/other/test_emit_tsd.d.ts index 06dc1288c2ffa..10e2499a8d67a 100644 --- a/test/other/test_emit_tsd.d.ts +++ b/test/other/test_emit_tsd.d.ts @@ -19,4 +19,4 @@ interface WasmModule { } export type MainModule = WasmModule & typeof RuntimeExports; -export default function MainModuleFactory (options?: unknown): Promise; +export default function MainModuleFactory (moduleOverrides?: Partial): Promise; diff --git a/test/other/test_emit_tsd_sync.d.ts b/test/other/test_emit_tsd_sync.d.ts index e3a1e55fd9944..5283b94f1693e 100644 --- a/test/other/test_emit_tsd_sync.d.ts +++ b/test/other/test_emit_tsd_sync.d.ts @@ -6,4 +6,4 @@ interface WasmModule { } export type MainModule = WasmModule; -export default function MainModuleFactory (options?: unknown): MainModule; +export default function MainModuleFactory (moduleOverrides?: Partial): MainModule; From 73e5ce81700fd835051f1d80b3929383df13983c Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 10 Apr 2025 11:33:37 -0700 Subject: [PATCH 3/3] oops --- src/postamble.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/postamble.js b/src/postamble.js index fba876fd58666..02864dcaf146a 100644 --- a/src/postamble.js +++ b/src/postamble.js @@ -300,8 +300,8 @@ function preInit() { } #if MODULARIZE == 'instance' -export default async function init(args = {}) { - moduleArgs = args; +export default async function init(moduleArg = {}) { + Module = moduleArg; processModuleArgs(); #if WASM_ESM_INTEGRATION updateMemoryViews();