Skip to content

Commit 91d9928

Browse files
author
jonas.ong
committed
fix type for wabt
1 parent 5a4aaee commit 91d9928

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/wasm-compiler/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import assert from "assert";
12
import wabt from "wabt";
23
import { Parser } from "../parser";
34
import { Tokenizer } from "../tokenizer";
@@ -19,7 +20,7 @@ export async function compileToWasmAndRun(code: string) {
1920
const wat = watGenerator.visit(watIR);
2021

2122
const w = await wabt();
22-
const wasm: Uint8Array = w.parseWat("a", wat).toBinary({}).buffer;
23+
const wasm = w.parseWat("a", wat).toBinary({}).buffer as BufferSource;
2324

2425
const memory = new WebAssembly.Memory({ initial: 1 });
2526

@@ -54,5 +55,6 @@ export async function compileToWasmAndRun(code: string) {
5455
});
5556

5657
// run the exported main function
57-
return (result as any).instance.exports.main() as [number, number];
58+
assert(typeof result.instance.exports.main === "function");
59+
return result.instance.exports.main() as [number, number];
5860
}

0 commit comments

Comments
 (0)