chiark / gitweb /
As an experiment change WebAssembly.Module to a class
authorWink Saville <wink@saville.com>
Sat, 1 Apr 2017 17:16:44 +0000 (10:16 -0700)
committerWink Saville <wink@saville.com>
Sat, 1 Apr 2017 17:16:44 +0000 (10:16 -0700)
Close but it's not compiling I get the following error:
```
$ yarn test
yarn test v0.21.3
$ tsc -p test/tsconfig.json
test/wasm.ts(136,3): error TS2322: Type 'ResultObject' is not assignable to type 'Instance'.
  Property 'exports' is missing in type 'ResultObject'.
error Command failed with exit code 2.
```

webassembly.d.ts

index 800da92b518f57993214124a68d650966e94738c..165cee99dbbe6a7598024ad6bc6b9ebc3c13a1d2 100644 (file)
@@ -6,25 +6,20 @@ declare namespace WebAssembly {
     /**
      * WebAssembly.Module
      **/
-    interface Module {
-        readonly [Symbol.toStringTag]: "Module";
-    }
+    class Module {
+        constructor (bufferSource: ArrayBuffer | Uint8Array);
 
-    interface ModuleConstructor {
-        readonly prototype: Module;
-        new(bufferSource: ArrayBuffer | Uint8Array): Module;
-        customSections(module: Module, sectionName: string): ArrayBuffer[];
-        exports(module: Module): {
+        static customSections(module: Module, sectionName: string): ArrayBuffer[];
+        static exports(module: Module): {
             name: string;
             kind: string;
         }[];
-        imports(module: Module): {
+        static imports(module: Module): {
             module: string;
             name: string;
             kind: string;
         }[];
     }
-    const Module: ModuleConstructor;
 
     /**
      * WebAssembly.Instance