From 1533728f595362d945a2a699605fc1233e723a57 Mon Sep 17 00:00:00 2001 From: Surma Date: Mon, 21 May 2018 13:34:42 +0100 Subject: [PATCH] Add types to module initialize func --- codecs/mozjpeg_enc/mozjpeg_enc.d.ts | 2 +- emscripten-wasm.d.ts | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/codecs/mozjpeg_enc/mozjpeg_enc.d.ts b/codecs/mozjpeg_enc/mozjpeg_enc.d.ts index c3a5a4bb..9f2e9ca1 100644 --- a/codecs/mozjpeg_enc/mozjpeg_enc.d.ts +++ b/codecs/mozjpeg_enc/mozjpeg_enc.d.ts @@ -1 +1 @@ -export default function(opts: {}): EmscriptenWasm.Module; +export default function(opts: EmscriptenWasm.ModuleOpts): EmscriptenWasm.Module; diff --git a/emscripten-wasm.d.ts b/emscripten-wasm.d.ts index f8988008..2d56197e 100644 --- a/emscripten-wasm.d.ts +++ b/emscripten-wasm.d.ts @@ -1,8 +1,16 @@ // These types roughly model the object that the JS files generated by Emscripten define. Copied from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/emscripten/index.d.ts and turned into a type definition rather than a global to support our way of using Emscripten. -// TODO(surma@): Upstream this? +// TODO(@surma): Upstream this? declare namespace EmscriptenWasm { type EnvironmentType = "WEB" | "NODE" | "SHELL" | "WORKER"; + // Options object for modularized Emscripten files. Shoe-horned by @surma. + // FIXME: This an incomplete definition! + interface ModuleOpts { + noInitialRun?: boolean; + locateFile?: (url: string) => string; + onRuntimeInitialized?: () => void; + } + interface Module { print(str: string): void; printErr(str: string): void; @@ -92,7 +100,7 @@ declare namespace EmscriptenWasm { _malloc(size: number): number; _free(ptr: number): void; - // Augmentations below by surma@ + // Augmentations below by @surma. onRuntimeInitialized: () => void | null; } }