chiark / gitweb /
Convert everything to classes.
authorWink Saville <wink@saville.com>
Sat, 1 Apr 2017 17:37:48 +0000 (10:37 -0700)
committerWink Saville <wink@saville.com>
Sat, 1 Apr 2017 17:37:48 +0000 (10:37 -0700)
Still getting the same 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 165cee99dbbe6a7598024ad6bc6b9ebc3c13a1d2..347ef08f5cf1baabbd3cb279326ad1aeb6f331a5 100644 (file)
@@ -24,17 +24,11 @@ declare namespace WebAssembly {
     /**
      * WebAssembly.Instance
      **/
-    interface Instance {
+    class Instance {
         readonly exports: any;
-        readonly [Symbol.toStringTag]: "Instance";
+        constructor (module: Module, importObject?: any);
     }
 
-    interface InstanceConstructor {
-        readonly prototype: Instance;
-        new(module: Module, importObject?: any): Instance;
-    }
-    const Instance: InstanceConstructor;
-
     /**
      * WebAssembly.Memory
      * Note: A WebAssembly page has a constant size of 65,536 bytes, i.e., 64KiB.
@@ -44,18 +38,12 @@ declare namespace WebAssembly {
         maximum?: number;
     }
 
-    interface Memory {
+    class Memory {
         readonly buffer: ArrayBuffer;
+        constructor (memoryDescriptor: MemoryDescriptor);
         grow(numPages: number): number;
-        readonly [Symbol.toStringTag]: "Memory";
     }
 
-    interface MemoryConstructor {
-        readonly prototype: Memory;
-        new (memoryDescriptor: MemoryDescriptor): Memory;
-    }
-    const Memory: MemoryConstructor;
-
     /**
      * WebAssembly.Table
      **/
@@ -65,58 +53,40 @@ declare namespace WebAssembly {
         maximum?: number;
     }
 
-    interface Table {
+    class Table {
         readonly length: number;
+        constructor (tableDescriptor: TableDescriptor);
         get(index: number): Function;
         grow(numElements: number): number;
         set(index: number, value: Function): void;
-        readonly [Symbol.toStringTag]: "Table";
     }
 
-    interface TableConstructor {
-        readonly prototype: Table;
-        new (tableDescriptor: TableDescriptor): Table;
-    }
-    const Table: TableConstructor;
-
     /**
      * Errors
      */
-    interface CompileError extends Error {
+    class CompileError extends Error {
         readonly fileName: string;
         readonly lineNumber: string;
         readonly columnNumber: string;
+        constructor (message?:string, fileName?:string, lineNumber?:number);
         toString(): string;
     }
-    interface CompileErrorConstructor {
-        readonly prototype: CompileError;
-        new (message?:string, fileName?:string, lineNumber?:number):CompileError;
-    }
-    const CompileError: CompileErrorConstructor;
 
-    interface LinkError extends Error {
+    class LinkError extends Error {
         readonly fileName: string;
         readonly lineNumber: string;
         readonly columnNumber: string;
+        constructor (message?:string, fileName?:string, lineNumber?:number);
         toString(): string;
     }
-    interface LinkErrorConstructor {
-        readonly prototype: LinkError;
-        new (message?:string, fileName?:string, lineNumber?:number):LinkError;
-    }
-    const LinkError: LinkErrorConstructor;
 
-    interface RuntimeError extends Error {
+    class RuntimeError extends Error {
         readonly fileName: string;
         readonly lineNumber: string;
         readonly columnNumber: string;
+        constructor (message?:string, fileName?:string, lineNumber?:number);
         toString(): string;
     }
-    interface RuntimeErrorConstructor {
-        readonly prototype: RuntimeError;
-        new (message?:string, fileName?:string, lineNumber?:number):RuntimeError;
-    }
-    const RuntimeError: RuntimeErrorConstructor;
 
     function compile(bufferSource: ArrayBuffer | Uint8Array): Promise<Module>;