Add types to module initialize func

This commit is contained in:
Surma
2018-05-21 13:34:42 +01:00
parent d4a616713a
commit 1533728f59
2 changed files with 11 additions and 3 deletions

View File

@@ -1 +1 @@
export default function(opts: {}): EmscriptenWasm.Module;
export default function(opts: EmscriptenWasm.ModuleOpts): EmscriptenWasm.Module;

12
emscripten-wasm.d.ts vendored
View File

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