Skip to content

Make images smaller using best-in-class codecs, right in the browser.

JavaScript

Add types to module initialize func

Surma1533728f5953
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;
}
}