From 46d57157d930db60e0176eb8be78fa9a83b6669a Mon Sep 17 00:00:00 2001 From: Sergey Rubanov Date: Mon, 19 Nov 2018 05:50:55 +0300 Subject: [PATCH] [WebAssembly] Align bufferSource value type to WebAssembly JS API Specification According to [WebAssembly JS API specification](https://webassembly.github.io/spec/js-api/#webassembly-namespace) `bufferSource` is of type `BufferSources` which is union of [these types](https://heycam.github.io/webidl/#BufferSource) importObject is always an object --- types/webassembly-js-api/index.d.ts | 14 +++++++++----- types/webassembly-web-api/index.d.ts | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/types/webassembly-js-api/index.d.ts b/types/webassembly-js-api/index.d.ts index 0c8c9d19e8..959e7c9ab5 100644 --- a/types/webassembly-js-api/index.d.ts +++ b/types/webassembly-js-api/index.d.ts @@ -3,7 +3,9 @@ // Definitions by: 01alchemist // Wink Saville // Periklis Tsirakidis +// Sergey Rubanov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 /** * The WebAssembly namespace, see [WebAssembly](https://github.com/webassembly) @@ -22,11 +24,13 @@ declare namespace WebAssembly { kind: string; }>; + type BufferSource = ArrayBufferView | ArrayBuffer; + /** * WebAssembly.Module */ class Module { - constructor(bufferSource: ArrayBuffer | Uint8Array); + constructor(bufferSource: BufferSource); static customSections(module: Module, sectionName: string): ArrayBuffer[]; static exports(module: Module): Imports; static imports(module: Module): Exports; @@ -99,15 +103,15 @@ declare namespace WebAssembly { toString(): string; } - function compile(bufferSource: ArrayBuffer | Uint8Array): Promise; + function compile(bufferSource: BufferSource): Promise; interface ResultObject { module: Module; instance: Instance; } - function instantiate(bufferSource: ArrayBuffer | Uint8Array, importObject?: any): Promise; - function instantiate(module: Module, importObject?: any): Promise; + function instantiate(bufferSource: BufferSource, importObject?: object): Promise; + function instantiate(module: Module, importObject?: object): Promise; - function validate(bufferSource: ArrayBuffer | Uint8Array): boolean; + function validate(bufferSource: BufferSource): boolean; } diff --git a/types/webassembly-web-api/index.d.ts b/types/webassembly-web-api/index.d.ts index fd53e094b2..974dd3ce21 100644 --- a/types/webassembly-web-api/index.d.ts +++ b/types/webassembly-web-api/index.d.ts @@ -13,5 +13,5 @@ */ declare namespace WebAssembly { function compileStreaming(source: Response | Promise): Promise; - function instantiateStreaming(source: Response | Promise, importObject?: any): Promise; + function instantiateStreaming(source: Response | Promise, importObject?: object): Promise; }