From 99df92c6ec18b64334cbea786c691c1667de20ff Mon Sep 17 00:00:00 2001 From: MartinFerret Date: Tue, 1 Dec 2026 10:49:16 +0100 Subject: [PATCH] Type 64-bit WebAssembly memories and tables with bigint addresses --- baselines/audioworklet.generated.d.ts | 43 +++-- baselines/dom.generated.d.ts | 43 +++-- baselines/serviceworker.generated.d.ts | 43 +++-- baselines/sharedworker.generated.d.ts | 43 +++-- baselines/ts5.5/audioworklet.generated.d.ts | 43 +++-- baselines/ts5.5/dom.generated.d.ts | 43 +++-- baselines/ts5.5/serviceworker.generated.d.ts | 43 +++-- baselines/ts5.5/sharedworker.generated.d.ts | 43 +++-- baselines/ts5.5/webworker.generated.d.ts | 43 +++-- baselines/ts5.6/audioworklet.generated.d.ts | 43 +++-- baselines/ts5.6/dom.generated.d.ts | 43 +++-- baselines/ts5.6/serviceworker.generated.d.ts | 43 +++-- baselines/ts5.6/sharedworker.generated.d.ts | 43 +++-- baselines/ts5.6/webworker.generated.d.ts | 43 +++-- baselines/ts5.9/audioworklet.generated.d.ts | 43 +++-- baselines/ts5.9/dom.generated.d.ts | 43 +++-- baselines/ts5.9/serviceworker.generated.d.ts | 43 +++-- baselines/ts5.9/sharedworker.generated.d.ts | 43 +++-- baselines/ts5.9/webworker.generated.d.ts | 43 +++-- baselines/webworker.generated.d.ts | 43 +++-- inputfiles/knownTypes.json | 3 + inputfiles/overridingTypes.jsonc | 101 ++++++++++- inputfiles/patches/webassembly.kdl | 10 +- unittests/files/webassemblyAddress.ts | 180 +++++++++++++++++++ 24 files changed, 769 insertions(+), 385 deletions(-) create mode 100644 unittests/files/webassemblyAddress.ts diff --git a/baselines/audioworklet.generated.d.ts b/baselines/audioworklet.generated.d.ts index 300b008b5..ca7c0ad22 100644 --- a/baselines/audioworklet.generated.d.ts +++ b/baselines/audioworklet.generated.d.ts @@ -1660,7 +1660,7 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory) */ - interface Memory { + interface Memory { /** * The read-only **`buffer`** prototype property of the WebAssembly.Memory object returns the buffer contained in the memory. Depending on whether or not the memory was constructed with shared: true, the buffer is either an ArrayBuffer or a SharedArrayBuffer. * @@ -1672,15 +1672,15 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory/grow) */ - grow(delta: AddressValue): AddressValue; + grow(delta: AddressValueMap[TAddress]): AddressValueMap[TAddress]; toFixedLengthBuffer(): TArrayBuffer; toResizableBuffer(): TArrayBuffer; } var Memory: { prototype: Memory; - new(descriptor: MemoryDescriptor & { shared?: false }): Memory; - new(descriptor: MemoryDescriptor): Memory; + new(descriptor: MemoryDescriptor & { shared?: false }): Memory; + new(descriptor: MemoryDescriptor): Memory; }; /** @@ -1729,36 +1729,36 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table) */ - interface Table { + interface Table { /** * The read-only **`length`** prototype property of the WebAssembly.Table object returns the length of the table, i.e., the number of elements in the table. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/length) */ - readonly length: AddressValue; + readonly length: AddressValueMap[TAddress]; /** * The **`get()`** prototype method of the WebAssembly.Table() object retrieves the element stored at a given index. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/get) */ - get(index: AddressValue): any; + get(index: AddressValueMap[TAddress]): any; /** * The **`grow()`** prototype method of the WebAssembly.Table object increases the size of the Table instance by a specified number of elements, filled with the provided value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/grow) */ - grow(delta: AddressValue, value?: any): AddressValue; + grow(delta: AddressValueMap[TAddress], value?: any): AddressValueMap[TAddress]; /** * The **`set()`** prototype method of the WebAssembly.Table object mutates a reference stored at a given index to a different value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/set) */ - set(index: AddressValue, value?: any): void; + set(index: AddressValueMap[TAddress], value?: any): void; } var Table: { prototype: Table; - new(descriptor: TableDescriptor, value?: any): Table; + new(descriptor: TableDescriptor, value?: any): Table; }; /** @@ -1774,6 +1774,11 @@ declare namespace WebAssembly { new(type: TagType): Tag; }; + interface AddressValueMap { + i32: number; + i64: bigint; + } + interface ExceptionOptions { traceStack?: boolean; } @@ -1783,10 +1788,10 @@ declare namespace WebAssembly { value: T; } - interface MemoryDescriptor { - address?: AddressType; - initial: AddressValue; - maximum?: AddressValue; + interface MemoryDescriptor { + address?: TAddress; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; shared?: boolean; } @@ -1801,11 +1806,11 @@ declare namespace WebAssembly { name: string; } - interface TableDescriptor { - address?: AddressType; + interface TableDescriptor { + address?: TAddress; element: TableKind; - initial: AddressValue; - maximum?: AddressValue; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; } interface TagType { @@ -1838,7 +1843,7 @@ declare namespace WebAssembly { type AddressValue = number; type ExportValue = Function | Global | Memory | Table; type Exports = Record; - type ImportValue = ExportValue | number; + type ImportValue = ExportValue | Memory | Table | number; type Imports = Record; type ModuleImports = Record; type ValueType = keyof ValueTypeMap; diff --git a/baselines/dom.generated.d.ts b/baselines/dom.generated.d.ts index c9f5ff7c7..d7bb59354 100644 --- a/baselines/dom.generated.d.ts +++ b/baselines/dom.generated.d.ts @@ -44096,7 +44096,7 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory) */ - interface Memory { + interface Memory { /** * The read-only **`buffer`** prototype property of the WebAssembly.Memory object returns the buffer contained in the memory. Depending on whether or not the memory was constructed with shared: true, the buffer is either an ArrayBuffer or a SharedArrayBuffer. * @@ -44108,15 +44108,15 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory/grow) */ - grow(delta: AddressValue): AddressValue; + grow(delta: AddressValueMap[TAddress]): AddressValueMap[TAddress]; toFixedLengthBuffer(): TArrayBuffer; toResizableBuffer(): TArrayBuffer; } var Memory: { prototype: Memory; - new(descriptor: MemoryDescriptor & { shared?: false }): Memory; - new(descriptor: MemoryDescriptor): Memory; + new(descriptor: MemoryDescriptor & { shared?: false }): Memory; + new(descriptor: MemoryDescriptor): Memory; }; /** @@ -44165,36 +44165,36 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table) */ - interface Table { + interface Table { /** * The read-only **`length`** prototype property of the WebAssembly.Table object returns the length of the table, i.e., the number of elements in the table. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/length) */ - readonly length: AddressValue; + readonly length: AddressValueMap[TAddress]; /** * The **`get()`** prototype method of the WebAssembly.Table() object retrieves the element stored at a given index. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/get) */ - get(index: AddressValue): any; + get(index: AddressValueMap[TAddress]): any; /** * The **`grow()`** prototype method of the WebAssembly.Table object increases the size of the Table instance by a specified number of elements, filled with the provided value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/grow) */ - grow(delta: AddressValue, value?: any): AddressValue; + grow(delta: AddressValueMap[TAddress], value?: any): AddressValueMap[TAddress]; /** * The **`set()`** prototype method of the WebAssembly.Table object mutates a reference stored at a given index to a different value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/set) */ - set(index: AddressValue, value?: any): void; + set(index: AddressValueMap[TAddress], value?: any): void; } var Table: { prototype: Table; - new(descriptor: TableDescriptor, value?: any): Table; + new(descriptor: TableDescriptor, value?: any): Table; }; /** @@ -44210,6 +44210,11 @@ declare namespace WebAssembly { new(type: TagType): Tag; }; + interface AddressValueMap { + i32: number; + i64: bigint; + } + interface ExceptionOptions { traceStack?: boolean; } @@ -44219,10 +44224,10 @@ declare namespace WebAssembly { value: T; } - interface MemoryDescriptor { - address?: AddressType; - initial: AddressValue; - maximum?: AddressValue; + interface MemoryDescriptor { + address?: TAddress; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; shared?: boolean; } @@ -44237,11 +44242,11 @@ declare namespace WebAssembly { name: string; } - interface TableDescriptor { - address?: AddressType; + interface TableDescriptor { + address?: TAddress; element: TableKind; - initial: AddressValue; - maximum?: AddressValue; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; } interface TagType { @@ -44274,7 +44279,7 @@ declare namespace WebAssembly { type AddressValue = number; type ExportValue = Function | Global | Memory | Table; type Exports = Record; - type ImportValue = ExportValue | number; + type ImportValue = ExportValue | Memory | Table | number; type Imports = Record; type ModuleImports = Record; type ValueType = keyof ValueTypeMap; diff --git a/baselines/serviceworker.generated.d.ts b/baselines/serviceworker.generated.d.ts index ab6c64050..19eee3dfd 100644 --- a/baselines/serviceworker.generated.d.ts +++ b/baselines/serviceworker.generated.d.ts @@ -13234,7 +13234,7 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory) */ - interface Memory { + interface Memory { /** * The read-only **`buffer`** prototype property of the WebAssembly.Memory object returns the buffer contained in the memory. Depending on whether or not the memory was constructed with shared: true, the buffer is either an ArrayBuffer or a SharedArrayBuffer. * @@ -13246,15 +13246,15 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory/grow) */ - grow(delta: AddressValue): AddressValue; + grow(delta: AddressValueMap[TAddress]): AddressValueMap[TAddress]; toFixedLengthBuffer(): TArrayBuffer; toResizableBuffer(): TArrayBuffer; } var Memory: { prototype: Memory; - new(descriptor: MemoryDescriptor & { shared?: false }): Memory; - new(descriptor: MemoryDescriptor): Memory; + new(descriptor: MemoryDescriptor & { shared?: false }): Memory; + new(descriptor: MemoryDescriptor): Memory; }; /** @@ -13303,36 +13303,36 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table) */ - interface Table { + interface Table { /** * The read-only **`length`** prototype property of the WebAssembly.Table object returns the length of the table, i.e., the number of elements in the table. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/length) */ - readonly length: AddressValue; + readonly length: AddressValueMap[TAddress]; /** * The **`get()`** prototype method of the WebAssembly.Table() object retrieves the element stored at a given index. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/get) */ - get(index: AddressValue): any; + get(index: AddressValueMap[TAddress]): any; /** * The **`grow()`** prototype method of the WebAssembly.Table object increases the size of the Table instance by a specified number of elements, filled with the provided value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/grow) */ - grow(delta: AddressValue, value?: any): AddressValue; + grow(delta: AddressValueMap[TAddress], value?: any): AddressValueMap[TAddress]; /** * The **`set()`** prototype method of the WebAssembly.Table object mutates a reference stored at a given index to a different value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/set) */ - set(index: AddressValue, value?: any): void; + set(index: AddressValueMap[TAddress], value?: any): void; } var Table: { prototype: Table; - new(descriptor: TableDescriptor, value?: any): Table; + new(descriptor: TableDescriptor, value?: any): Table; }; /** @@ -13348,6 +13348,11 @@ declare namespace WebAssembly { new(type: TagType): Tag; }; + interface AddressValueMap { + i32: number; + i64: bigint; + } + interface ExceptionOptions { traceStack?: boolean; } @@ -13357,10 +13362,10 @@ declare namespace WebAssembly { value: T; } - interface MemoryDescriptor { - address?: AddressType; - initial: AddressValue; - maximum?: AddressValue; + interface MemoryDescriptor { + address?: TAddress; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; shared?: boolean; } @@ -13375,11 +13380,11 @@ declare namespace WebAssembly { name: string; } - interface TableDescriptor { - address?: AddressType; + interface TableDescriptor { + address?: TAddress; element: TableKind; - initial: AddressValue; - maximum?: AddressValue; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; } interface TagType { @@ -13412,7 +13417,7 @@ declare namespace WebAssembly { type AddressValue = number; type ExportValue = Function | Global | Memory | Table; type Exports = Record; - type ImportValue = ExportValue | number; + type ImportValue = ExportValue | Memory | Table | number; type Imports = Record; type ModuleImports = Record; type ValueType = keyof ValueTypeMap; diff --git a/baselines/sharedworker.generated.d.ts b/baselines/sharedworker.generated.d.ts index 473cc7856..5216eeb58 100644 --- a/baselines/sharedworker.generated.d.ts +++ b/baselines/sharedworker.generated.d.ts @@ -12922,7 +12922,7 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory) */ - interface Memory { + interface Memory { /** * The read-only **`buffer`** prototype property of the WebAssembly.Memory object returns the buffer contained in the memory. Depending on whether or not the memory was constructed with shared: true, the buffer is either an ArrayBuffer or a SharedArrayBuffer. * @@ -12934,15 +12934,15 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory/grow) */ - grow(delta: AddressValue): AddressValue; + grow(delta: AddressValueMap[TAddress]): AddressValueMap[TAddress]; toFixedLengthBuffer(): TArrayBuffer; toResizableBuffer(): TArrayBuffer; } var Memory: { prototype: Memory; - new(descriptor: MemoryDescriptor & { shared?: false }): Memory; - new(descriptor: MemoryDescriptor): Memory; + new(descriptor: MemoryDescriptor & { shared?: false }): Memory; + new(descriptor: MemoryDescriptor): Memory; }; /** @@ -12991,36 +12991,36 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table) */ - interface Table { + interface Table { /** * The read-only **`length`** prototype property of the WebAssembly.Table object returns the length of the table, i.e., the number of elements in the table. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/length) */ - readonly length: AddressValue; + readonly length: AddressValueMap[TAddress]; /** * The **`get()`** prototype method of the WebAssembly.Table() object retrieves the element stored at a given index. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/get) */ - get(index: AddressValue): any; + get(index: AddressValueMap[TAddress]): any; /** * The **`grow()`** prototype method of the WebAssembly.Table object increases the size of the Table instance by a specified number of elements, filled with the provided value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/grow) */ - grow(delta: AddressValue, value?: any): AddressValue; + grow(delta: AddressValueMap[TAddress], value?: any): AddressValueMap[TAddress]; /** * The **`set()`** prototype method of the WebAssembly.Table object mutates a reference stored at a given index to a different value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/set) */ - set(index: AddressValue, value?: any): void; + set(index: AddressValueMap[TAddress], value?: any): void; } var Table: { prototype: Table; - new(descriptor: TableDescriptor, value?: any): Table; + new(descriptor: TableDescriptor, value?: any): Table; }; /** @@ -13036,6 +13036,11 @@ declare namespace WebAssembly { new(type: TagType): Tag; }; + interface AddressValueMap { + i32: number; + i64: bigint; + } + interface ExceptionOptions { traceStack?: boolean; } @@ -13045,10 +13050,10 @@ declare namespace WebAssembly { value: T; } - interface MemoryDescriptor { - address?: AddressType; - initial: AddressValue; - maximum?: AddressValue; + interface MemoryDescriptor { + address?: TAddress; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; shared?: boolean; } @@ -13063,11 +13068,11 @@ declare namespace WebAssembly { name: string; } - interface TableDescriptor { - address?: AddressType; + interface TableDescriptor { + address?: TAddress; element: TableKind; - initial: AddressValue; - maximum?: AddressValue; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; } interface TagType { @@ -13100,7 +13105,7 @@ declare namespace WebAssembly { type AddressValue = number; type ExportValue = Function | Global | Memory | Table; type Exports = Record; - type ImportValue = ExportValue | number; + type ImportValue = ExportValue | Memory | Table | number; type Imports = Record; type ModuleImports = Record; type ValueType = keyof ValueTypeMap; diff --git a/baselines/ts5.5/audioworklet.generated.d.ts b/baselines/ts5.5/audioworklet.generated.d.ts index 519563605..4d5db9a80 100644 --- a/baselines/ts5.5/audioworklet.generated.d.ts +++ b/baselines/ts5.5/audioworklet.generated.d.ts @@ -1657,7 +1657,7 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory) */ - interface Memory { + interface Memory { /** * The read-only **`buffer`** prototype property of the WebAssembly.Memory object returns the buffer contained in the memory. Depending on whether or not the memory was constructed with shared: true, the buffer is either an ArrayBuffer or a SharedArrayBuffer. * @@ -1669,15 +1669,15 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory/grow) */ - grow(delta: AddressValue): AddressValue; + grow(delta: AddressValueMap[TAddress]): AddressValueMap[TAddress]; toFixedLengthBuffer(): TArrayBuffer; toResizableBuffer(): TArrayBuffer; } var Memory: { prototype: Memory; - new(descriptor: MemoryDescriptor & { shared?: false }): Memory; - new(descriptor: MemoryDescriptor): Memory; + new(descriptor: MemoryDescriptor & { shared?: false }): Memory; + new(descriptor: MemoryDescriptor): Memory; }; /** @@ -1726,36 +1726,36 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table) */ - interface Table { + interface Table { /** * The read-only **`length`** prototype property of the WebAssembly.Table object returns the length of the table, i.e., the number of elements in the table. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/length) */ - readonly length: AddressValue; + readonly length: AddressValueMap[TAddress]; /** * The **`get()`** prototype method of the WebAssembly.Table() object retrieves the element stored at a given index. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/get) */ - get(index: AddressValue): any; + get(index: AddressValueMap[TAddress]): any; /** * The **`grow()`** prototype method of the WebAssembly.Table object increases the size of the Table instance by a specified number of elements, filled with the provided value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/grow) */ - grow(delta: AddressValue, value?: any): AddressValue; + grow(delta: AddressValueMap[TAddress], value?: any): AddressValueMap[TAddress]; /** * The **`set()`** prototype method of the WebAssembly.Table object mutates a reference stored at a given index to a different value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/set) */ - set(index: AddressValue, value?: any): void; + set(index: AddressValueMap[TAddress], value?: any): void; } var Table: { prototype: Table; - new(descriptor: TableDescriptor, value?: any): Table; + new(descriptor: TableDescriptor, value?: any): Table; }; /** @@ -1771,6 +1771,11 @@ declare namespace WebAssembly { new(type: TagType): Tag; }; + interface AddressValueMap { + i32: number; + i64: bigint; + } + interface ExceptionOptions { traceStack?: boolean; } @@ -1780,10 +1785,10 @@ declare namespace WebAssembly { value: T; } - interface MemoryDescriptor { - address?: AddressType; - initial: AddressValue; - maximum?: AddressValue; + interface MemoryDescriptor { + address?: TAddress; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; shared?: boolean; } @@ -1798,11 +1803,11 @@ declare namespace WebAssembly { name: string; } - interface TableDescriptor { - address?: AddressType; + interface TableDescriptor { + address?: TAddress; element: TableKind; - initial: AddressValue; - maximum?: AddressValue; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; } interface TagType { @@ -1835,7 +1840,7 @@ declare namespace WebAssembly { type AddressValue = number; type ExportValue = Function | Global | Memory | Table; type Exports = Record; - type ImportValue = ExportValue | number; + type ImportValue = ExportValue | Memory | Table | number; type Imports = Record; type ModuleImports = Record; type ValueType = keyof ValueTypeMap; diff --git a/baselines/ts5.5/dom.generated.d.ts b/baselines/ts5.5/dom.generated.d.ts index 86ff6b6a3..52ed44e50 100644 --- a/baselines/ts5.5/dom.generated.d.ts +++ b/baselines/ts5.5/dom.generated.d.ts @@ -44070,7 +44070,7 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory) */ - interface Memory { + interface Memory { /** * The read-only **`buffer`** prototype property of the WebAssembly.Memory object returns the buffer contained in the memory. Depending on whether or not the memory was constructed with shared: true, the buffer is either an ArrayBuffer or a SharedArrayBuffer. * @@ -44082,15 +44082,15 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory/grow) */ - grow(delta: AddressValue): AddressValue; + grow(delta: AddressValueMap[TAddress]): AddressValueMap[TAddress]; toFixedLengthBuffer(): TArrayBuffer; toResizableBuffer(): TArrayBuffer; } var Memory: { prototype: Memory; - new(descriptor: MemoryDescriptor & { shared?: false }): Memory; - new(descriptor: MemoryDescriptor): Memory; + new(descriptor: MemoryDescriptor & { shared?: false }): Memory; + new(descriptor: MemoryDescriptor): Memory; }; /** @@ -44139,36 +44139,36 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table) */ - interface Table { + interface Table { /** * The read-only **`length`** prototype property of the WebAssembly.Table object returns the length of the table, i.e., the number of elements in the table. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/length) */ - readonly length: AddressValue; + readonly length: AddressValueMap[TAddress]; /** * The **`get()`** prototype method of the WebAssembly.Table() object retrieves the element stored at a given index. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/get) */ - get(index: AddressValue): any; + get(index: AddressValueMap[TAddress]): any; /** * The **`grow()`** prototype method of the WebAssembly.Table object increases the size of the Table instance by a specified number of elements, filled with the provided value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/grow) */ - grow(delta: AddressValue, value?: any): AddressValue; + grow(delta: AddressValueMap[TAddress], value?: any): AddressValueMap[TAddress]; /** * The **`set()`** prototype method of the WebAssembly.Table object mutates a reference stored at a given index to a different value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/set) */ - set(index: AddressValue, value?: any): void; + set(index: AddressValueMap[TAddress], value?: any): void; } var Table: { prototype: Table; - new(descriptor: TableDescriptor, value?: any): Table; + new(descriptor: TableDescriptor, value?: any): Table; }; /** @@ -44184,6 +44184,11 @@ declare namespace WebAssembly { new(type: TagType): Tag; }; + interface AddressValueMap { + i32: number; + i64: bigint; + } + interface ExceptionOptions { traceStack?: boolean; } @@ -44193,10 +44198,10 @@ declare namespace WebAssembly { value: T; } - interface MemoryDescriptor { - address?: AddressType; - initial: AddressValue; - maximum?: AddressValue; + interface MemoryDescriptor { + address?: TAddress; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; shared?: boolean; } @@ -44211,11 +44216,11 @@ declare namespace WebAssembly { name: string; } - interface TableDescriptor { - address?: AddressType; + interface TableDescriptor { + address?: TAddress; element: TableKind; - initial: AddressValue; - maximum?: AddressValue; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; } interface TagType { @@ -44248,7 +44253,7 @@ declare namespace WebAssembly { type AddressValue = number; type ExportValue = Function | Global | Memory | Table; type Exports = Record; - type ImportValue = ExportValue | number; + type ImportValue = ExportValue | Memory | Table | number; type Imports = Record; type ModuleImports = Record; type ValueType = keyof ValueTypeMap; diff --git a/baselines/ts5.5/serviceworker.generated.d.ts b/baselines/ts5.5/serviceworker.generated.d.ts index 494c452b4..6d60fb7fb 100644 --- a/baselines/ts5.5/serviceworker.generated.d.ts +++ b/baselines/ts5.5/serviceworker.generated.d.ts @@ -13231,7 +13231,7 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory) */ - interface Memory { + interface Memory { /** * The read-only **`buffer`** prototype property of the WebAssembly.Memory object returns the buffer contained in the memory. Depending on whether or not the memory was constructed with shared: true, the buffer is either an ArrayBuffer or a SharedArrayBuffer. * @@ -13243,15 +13243,15 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory/grow) */ - grow(delta: AddressValue): AddressValue; + grow(delta: AddressValueMap[TAddress]): AddressValueMap[TAddress]; toFixedLengthBuffer(): TArrayBuffer; toResizableBuffer(): TArrayBuffer; } var Memory: { prototype: Memory; - new(descriptor: MemoryDescriptor & { shared?: false }): Memory; - new(descriptor: MemoryDescriptor): Memory; + new(descriptor: MemoryDescriptor & { shared?: false }): Memory; + new(descriptor: MemoryDescriptor): Memory; }; /** @@ -13300,36 +13300,36 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table) */ - interface Table { + interface Table { /** * The read-only **`length`** prototype property of the WebAssembly.Table object returns the length of the table, i.e., the number of elements in the table. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/length) */ - readonly length: AddressValue; + readonly length: AddressValueMap[TAddress]; /** * The **`get()`** prototype method of the WebAssembly.Table() object retrieves the element stored at a given index. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/get) */ - get(index: AddressValue): any; + get(index: AddressValueMap[TAddress]): any; /** * The **`grow()`** prototype method of the WebAssembly.Table object increases the size of the Table instance by a specified number of elements, filled with the provided value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/grow) */ - grow(delta: AddressValue, value?: any): AddressValue; + grow(delta: AddressValueMap[TAddress], value?: any): AddressValueMap[TAddress]; /** * The **`set()`** prototype method of the WebAssembly.Table object mutates a reference stored at a given index to a different value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/set) */ - set(index: AddressValue, value?: any): void; + set(index: AddressValueMap[TAddress], value?: any): void; } var Table: { prototype: Table; - new(descriptor: TableDescriptor, value?: any): Table; + new(descriptor: TableDescriptor, value?: any): Table; }; /** @@ -13345,6 +13345,11 @@ declare namespace WebAssembly { new(type: TagType): Tag; }; + interface AddressValueMap { + i32: number; + i64: bigint; + } + interface ExceptionOptions { traceStack?: boolean; } @@ -13354,10 +13359,10 @@ declare namespace WebAssembly { value: T; } - interface MemoryDescriptor { - address?: AddressType; - initial: AddressValue; - maximum?: AddressValue; + interface MemoryDescriptor { + address?: TAddress; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; shared?: boolean; } @@ -13372,11 +13377,11 @@ declare namespace WebAssembly { name: string; } - interface TableDescriptor { - address?: AddressType; + interface TableDescriptor { + address?: TAddress; element: TableKind; - initial: AddressValue; - maximum?: AddressValue; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; } interface TagType { @@ -13409,7 +13414,7 @@ declare namespace WebAssembly { type AddressValue = number; type ExportValue = Function | Global | Memory | Table; type Exports = Record; - type ImportValue = ExportValue | number; + type ImportValue = ExportValue | Memory | Table | number; type Imports = Record; type ModuleImports = Record; type ValueType = keyof ValueTypeMap; diff --git a/baselines/ts5.5/sharedworker.generated.d.ts b/baselines/ts5.5/sharedworker.generated.d.ts index 09d6dcc63..899a1aeef 100644 --- a/baselines/ts5.5/sharedworker.generated.d.ts +++ b/baselines/ts5.5/sharedworker.generated.d.ts @@ -12919,7 +12919,7 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory) */ - interface Memory { + interface Memory { /** * The read-only **`buffer`** prototype property of the WebAssembly.Memory object returns the buffer contained in the memory. Depending on whether or not the memory was constructed with shared: true, the buffer is either an ArrayBuffer or a SharedArrayBuffer. * @@ -12931,15 +12931,15 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory/grow) */ - grow(delta: AddressValue): AddressValue; + grow(delta: AddressValueMap[TAddress]): AddressValueMap[TAddress]; toFixedLengthBuffer(): TArrayBuffer; toResizableBuffer(): TArrayBuffer; } var Memory: { prototype: Memory; - new(descriptor: MemoryDescriptor & { shared?: false }): Memory; - new(descriptor: MemoryDescriptor): Memory; + new(descriptor: MemoryDescriptor & { shared?: false }): Memory; + new(descriptor: MemoryDescriptor): Memory; }; /** @@ -12988,36 +12988,36 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table) */ - interface Table { + interface Table { /** * The read-only **`length`** prototype property of the WebAssembly.Table object returns the length of the table, i.e., the number of elements in the table. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/length) */ - readonly length: AddressValue; + readonly length: AddressValueMap[TAddress]; /** * The **`get()`** prototype method of the WebAssembly.Table() object retrieves the element stored at a given index. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/get) */ - get(index: AddressValue): any; + get(index: AddressValueMap[TAddress]): any; /** * The **`grow()`** prototype method of the WebAssembly.Table object increases the size of the Table instance by a specified number of elements, filled with the provided value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/grow) */ - grow(delta: AddressValue, value?: any): AddressValue; + grow(delta: AddressValueMap[TAddress], value?: any): AddressValueMap[TAddress]; /** * The **`set()`** prototype method of the WebAssembly.Table object mutates a reference stored at a given index to a different value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/set) */ - set(index: AddressValue, value?: any): void; + set(index: AddressValueMap[TAddress], value?: any): void; } var Table: { prototype: Table; - new(descriptor: TableDescriptor, value?: any): Table; + new(descriptor: TableDescriptor, value?: any): Table; }; /** @@ -13033,6 +13033,11 @@ declare namespace WebAssembly { new(type: TagType): Tag; }; + interface AddressValueMap { + i32: number; + i64: bigint; + } + interface ExceptionOptions { traceStack?: boolean; } @@ -13042,10 +13047,10 @@ declare namespace WebAssembly { value: T; } - interface MemoryDescriptor { - address?: AddressType; - initial: AddressValue; - maximum?: AddressValue; + interface MemoryDescriptor { + address?: TAddress; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; shared?: boolean; } @@ -13060,11 +13065,11 @@ declare namespace WebAssembly { name: string; } - interface TableDescriptor { - address?: AddressType; + interface TableDescriptor { + address?: TAddress; element: TableKind; - initial: AddressValue; - maximum?: AddressValue; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; } interface TagType { @@ -13097,7 +13102,7 @@ declare namespace WebAssembly { type AddressValue = number; type ExportValue = Function | Global | Memory | Table; type Exports = Record; - type ImportValue = ExportValue | number; + type ImportValue = ExportValue | Memory | Table | number; type Imports = Record; type ModuleImports = Record; type ValueType = keyof ValueTypeMap; diff --git a/baselines/ts5.5/webworker.generated.d.ts b/baselines/ts5.5/webworker.generated.d.ts index 424a26382..edd7228a3 100644 --- a/baselines/ts5.5/webworker.generated.d.ts +++ b/baselines/ts5.5/webworker.generated.d.ts @@ -15041,7 +15041,7 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory) */ - interface Memory { + interface Memory { /** * The read-only **`buffer`** prototype property of the WebAssembly.Memory object returns the buffer contained in the memory. Depending on whether or not the memory was constructed with shared: true, the buffer is either an ArrayBuffer or a SharedArrayBuffer. * @@ -15053,15 +15053,15 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory/grow) */ - grow(delta: AddressValue): AddressValue; + grow(delta: AddressValueMap[TAddress]): AddressValueMap[TAddress]; toFixedLengthBuffer(): TArrayBuffer; toResizableBuffer(): TArrayBuffer; } var Memory: { prototype: Memory; - new(descriptor: MemoryDescriptor & { shared?: false }): Memory; - new(descriptor: MemoryDescriptor): Memory; + new(descriptor: MemoryDescriptor & { shared?: false }): Memory; + new(descriptor: MemoryDescriptor): Memory; }; /** @@ -15110,36 +15110,36 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table) */ - interface Table { + interface Table { /** * The read-only **`length`** prototype property of the WebAssembly.Table object returns the length of the table, i.e., the number of elements in the table. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/length) */ - readonly length: AddressValue; + readonly length: AddressValueMap[TAddress]; /** * The **`get()`** prototype method of the WebAssembly.Table() object retrieves the element stored at a given index. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/get) */ - get(index: AddressValue): any; + get(index: AddressValueMap[TAddress]): any; /** * The **`grow()`** prototype method of the WebAssembly.Table object increases the size of the Table instance by a specified number of elements, filled with the provided value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/grow) */ - grow(delta: AddressValue, value?: any): AddressValue; + grow(delta: AddressValueMap[TAddress], value?: any): AddressValueMap[TAddress]; /** * The **`set()`** prototype method of the WebAssembly.Table object mutates a reference stored at a given index to a different value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/set) */ - set(index: AddressValue, value?: any): void; + set(index: AddressValueMap[TAddress], value?: any): void; } var Table: { prototype: Table; - new(descriptor: TableDescriptor, value?: any): Table; + new(descriptor: TableDescriptor, value?: any): Table; }; /** @@ -15155,6 +15155,11 @@ declare namespace WebAssembly { new(type: TagType): Tag; }; + interface AddressValueMap { + i32: number; + i64: bigint; + } + interface ExceptionOptions { traceStack?: boolean; } @@ -15164,10 +15169,10 @@ declare namespace WebAssembly { value: T; } - interface MemoryDescriptor { - address?: AddressType; - initial: AddressValue; - maximum?: AddressValue; + interface MemoryDescriptor { + address?: TAddress; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; shared?: boolean; } @@ -15182,11 +15187,11 @@ declare namespace WebAssembly { name: string; } - interface TableDescriptor { - address?: AddressType; + interface TableDescriptor { + address?: TAddress; element: TableKind; - initial: AddressValue; - maximum?: AddressValue; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; } interface TagType { @@ -15219,7 +15224,7 @@ declare namespace WebAssembly { type AddressValue = number; type ExportValue = Function | Global | Memory | Table; type Exports = Record; - type ImportValue = ExportValue | number; + type ImportValue = ExportValue | Memory | Table | number; type Imports = Record; type ModuleImports = Record; type ValueType = keyof ValueTypeMap; diff --git a/baselines/ts5.6/audioworklet.generated.d.ts b/baselines/ts5.6/audioworklet.generated.d.ts index 519563605..4d5db9a80 100644 --- a/baselines/ts5.6/audioworklet.generated.d.ts +++ b/baselines/ts5.6/audioworklet.generated.d.ts @@ -1657,7 +1657,7 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory) */ - interface Memory { + interface Memory { /** * The read-only **`buffer`** prototype property of the WebAssembly.Memory object returns the buffer contained in the memory. Depending on whether or not the memory was constructed with shared: true, the buffer is either an ArrayBuffer or a SharedArrayBuffer. * @@ -1669,15 +1669,15 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory/grow) */ - grow(delta: AddressValue): AddressValue; + grow(delta: AddressValueMap[TAddress]): AddressValueMap[TAddress]; toFixedLengthBuffer(): TArrayBuffer; toResizableBuffer(): TArrayBuffer; } var Memory: { prototype: Memory; - new(descriptor: MemoryDescriptor & { shared?: false }): Memory; - new(descriptor: MemoryDescriptor): Memory; + new(descriptor: MemoryDescriptor & { shared?: false }): Memory; + new(descriptor: MemoryDescriptor): Memory; }; /** @@ -1726,36 +1726,36 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table) */ - interface Table { + interface Table { /** * The read-only **`length`** prototype property of the WebAssembly.Table object returns the length of the table, i.e., the number of elements in the table. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/length) */ - readonly length: AddressValue; + readonly length: AddressValueMap[TAddress]; /** * The **`get()`** prototype method of the WebAssembly.Table() object retrieves the element stored at a given index. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/get) */ - get(index: AddressValue): any; + get(index: AddressValueMap[TAddress]): any; /** * The **`grow()`** prototype method of the WebAssembly.Table object increases the size of the Table instance by a specified number of elements, filled with the provided value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/grow) */ - grow(delta: AddressValue, value?: any): AddressValue; + grow(delta: AddressValueMap[TAddress], value?: any): AddressValueMap[TAddress]; /** * The **`set()`** prototype method of the WebAssembly.Table object mutates a reference stored at a given index to a different value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/set) */ - set(index: AddressValue, value?: any): void; + set(index: AddressValueMap[TAddress], value?: any): void; } var Table: { prototype: Table; - new(descriptor: TableDescriptor, value?: any): Table; + new(descriptor: TableDescriptor, value?: any): Table; }; /** @@ -1771,6 +1771,11 @@ declare namespace WebAssembly { new(type: TagType): Tag; }; + interface AddressValueMap { + i32: number; + i64: bigint; + } + interface ExceptionOptions { traceStack?: boolean; } @@ -1780,10 +1785,10 @@ declare namespace WebAssembly { value: T; } - interface MemoryDescriptor { - address?: AddressType; - initial: AddressValue; - maximum?: AddressValue; + interface MemoryDescriptor { + address?: TAddress; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; shared?: boolean; } @@ -1798,11 +1803,11 @@ declare namespace WebAssembly { name: string; } - interface TableDescriptor { - address?: AddressType; + interface TableDescriptor { + address?: TAddress; element: TableKind; - initial: AddressValue; - maximum?: AddressValue; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; } interface TagType { @@ -1835,7 +1840,7 @@ declare namespace WebAssembly { type AddressValue = number; type ExportValue = Function | Global | Memory | Table; type Exports = Record; - type ImportValue = ExportValue | number; + type ImportValue = ExportValue | Memory | Table | number; type Imports = Record; type ModuleImports = Record; type ValueType = keyof ValueTypeMap; diff --git a/baselines/ts5.6/dom.generated.d.ts b/baselines/ts5.6/dom.generated.d.ts index 02ce861a0..f55451605 100644 --- a/baselines/ts5.6/dom.generated.d.ts +++ b/baselines/ts5.6/dom.generated.d.ts @@ -44093,7 +44093,7 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory) */ - interface Memory { + interface Memory { /** * The read-only **`buffer`** prototype property of the WebAssembly.Memory object returns the buffer contained in the memory. Depending on whether or not the memory was constructed with shared: true, the buffer is either an ArrayBuffer or a SharedArrayBuffer. * @@ -44105,15 +44105,15 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory/grow) */ - grow(delta: AddressValue): AddressValue; + grow(delta: AddressValueMap[TAddress]): AddressValueMap[TAddress]; toFixedLengthBuffer(): TArrayBuffer; toResizableBuffer(): TArrayBuffer; } var Memory: { prototype: Memory; - new(descriptor: MemoryDescriptor & { shared?: false }): Memory; - new(descriptor: MemoryDescriptor): Memory; + new(descriptor: MemoryDescriptor & { shared?: false }): Memory; + new(descriptor: MemoryDescriptor): Memory; }; /** @@ -44162,36 +44162,36 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table) */ - interface Table { + interface Table { /** * The read-only **`length`** prototype property of the WebAssembly.Table object returns the length of the table, i.e., the number of elements in the table. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/length) */ - readonly length: AddressValue; + readonly length: AddressValueMap[TAddress]; /** * The **`get()`** prototype method of the WebAssembly.Table() object retrieves the element stored at a given index. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/get) */ - get(index: AddressValue): any; + get(index: AddressValueMap[TAddress]): any; /** * The **`grow()`** prototype method of the WebAssembly.Table object increases the size of the Table instance by a specified number of elements, filled with the provided value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/grow) */ - grow(delta: AddressValue, value?: any): AddressValue; + grow(delta: AddressValueMap[TAddress], value?: any): AddressValueMap[TAddress]; /** * The **`set()`** prototype method of the WebAssembly.Table object mutates a reference stored at a given index to a different value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/set) */ - set(index: AddressValue, value?: any): void; + set(index: AddressValueMap[TAddress], value?: any): void; } var Table: { prototype: Table; - new(descriptor: TableDescriptor, value?: any): Table; + new(descriptor: TableDescriptor, value?: any): Table; }; /** @@ -44207,6 +44207,11 @@ declare namespace WebAssembly { new(type: TagType): Tag; }; + interface AddressValueMap { + i32: number; + i64: bigint; + } + interface ExceptionOptions { traceStack?: boolean; } @@ -44216,10 +44221,10 @@ declare namespace WebAssembly { value: T; } - interface MemoryDescriptor { - address?: AddressType; - initial: AddressValue; - maximum?: AddressValue; + interface MemoryDescriptor { + address?: TAddress; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; shared?: boolean; } @@ -44234,11 +44239,11 @@ declare namespace WebAssembly { name: string; } - interface TableDescriptor { - address?: AddressType; + interface TableDescriptor { + address?: TAddress; element: TableKind; - initial: AddressValue; - maximum?: AddressValue; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; } interface TagType { @@ -44271,7 +44276,7 @@ declare namespace WebAssembly { type AddressValue = number; type ExportValue = Function | Global | Memory | Table; type Exports = Record; - type ImportValue = ExportValue | number; + type ImportValue = ExportValue | Memory | Table | number; type Imports = Record; type ModuleImports = Record; type ValueType = keyof ValueTypeMap; diff --git a/baselines/ts5.6/serviceworker.generated.d.ts b/baselines/ts5.6/serviceworker.generated.d.ts index 494c452b4..6d60fb7fb 100644 --- a/baselines/ts5.6/serviceworker.generated.d.ts +++ b/baselines/ts5.6/serviceworker.generated.d.ts @@ -13231,7 +13231,7 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory) */ - interface Memory { + interface Memory { /** * The read-only **`buffer`** prototype property of the WebAssembly.Memory object returns the buffer contained in the memory. Depending on whether or not the memory was constructed with shared: true, the buffer is either an ArrayBuffer or a SharedArrayBuffer. * @@ -13243,15 +13243,15 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory/grow) */ - grow(delta: AddressValue): AddressValue; + grow(delta: AddressValueMap[TAddress]): AddressValueMap[TAddress]; toFixedLengthBuffer(): TArrayBuffer; toResizableBuffer(): TArrayBuffer; } var Memory: { prototype: Memory; - new(descriptor: MemoryDescriptor & { shared?: false }): Memory; - new(descriptor: MemoryDescriptor): Memory; + new(descriptor: MemoryDescriptor & { shared?: false }): Memory; + new(descriptor: MemoryDescriptor): Memory; }; /** @@ -13300,36 +13300,36 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table) */ - interface Table { + interface Table { /** * The read-only **`length`** prototype property of the WebAssembly.Table object returns the length of the table, i.e., the number of elements in the table. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/length) */ - readonly length: AddressValue; + readonly length: AddressValueMap[TAddress]; /** * The **`get()`** prototype method of the WebAssembly.Table() object retrieves the element stored at a given index. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/get) */ - get(index: AddressValue): any; + get(index: AddressValueMap[TAddress]): any; /** * The **`grow()`** prototype method of the WebAssembly.Table object increases the size of the Table instance by a specified number of elements, filled with the provided value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/grow) */ - grow(delta: AddressValue, value?: any): AddressValue; + grow(delta: AddressValueMap[TAddress], value?: any): AddressValueMap[TAddress]; /** * The **`set()`** prototype method of the WebAssembly.Table object mutates a reference stored at a given index to a different value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/set) */ - set(index: AddressValue, value?: any): void; + set(index: AddressValueMap[TAddress], value?: any): void; } var Table: { prototype: Table; - new(descriptor: TableDescriptor, value?: any): Table; + new(descriptor: TableDescriptor, value?: any): Table; }; /** @@ -13345,6 +13345,11 @@ declare namespace WebAssembly { new(type: TagType): Tag; }; + interface AddressValueMap { + i32: number; + i64: bigint; + } + interface ExceptionOptions { traceStack?: boolean; } @@ -13354,10 +13359,10 @@ declare namespace WebAssembly { value: T; } - interface MemoryDescriptor { - address?: AddressType; - initial: AddressValue; - maximum?: AddressValue; + interface MemoryDescriptor { + address?: TAddress; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; shared?: boolean; } @@ -13372,11 +13377,11 @@ declare namespace WebAssembly { name: string; } - interface TableDescriptor { - address?: AddressType; + interface TableDescriptor { + address?: TAddress; element: TableKind; - initial: AddressValue; - maximum?: AddressValue; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; } interface TagType { @@ -13409,7 +13414,7 @@ declare namespace WebAssembly { type AddressValue = number; type ExportValue = Function | Global | Memory | Table; type Exports = Record; - type ImportValue = ExportValue | number; + type ImportValue = ExportValue | Memory | Table | number; type Imports = Record; type ModuleImports = Record; type ValueType = keyof ValueTypeMap; diff --git a/baselines/ts5.6/sharedworker.generated.d.ts b/baselines/ts5.6/sharedworker.generated.d.ts index 09d6dcc63..899a1aeef 100644 --- a/baselines/ts5.6/sharedworker.generated.d.ts +++ b/baselines/ts5.6/sharedworker.generated.d.ts @@ -12919,7 +12919,7 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory) */ - interface Memory { + interface Memory { /** * The read-only **`buffer`** prototype property of the WebAssembly.Memory object returns the buffer contained in the memory. Depending on whether or not the memory was constructed with shared: true, the buffer is either an ArrayBuffer or a SharedArrayBuffer. * @@ -12931,15 +12931,15 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory/grow) */ - grow(delta: AddressValue): AddressValue; + grow(delta: AddressValueMap[TAddress]): AddressValueMap[TAddress]; toFixedLengthBuffer(): TArrayBuffer; toResizableBuffer(): TArrayBuffer; } var Memory: { prototype: Memory; - new(descriptor: MemoryDescriptor & { shared?: false }): Memory; - new(descriptor: MemoryDescriptor): Memory; + new(descriptor: MemoryDescriptor & { shared?: false }): Memory; + new(descriptor: MemoryDescriptor): Memory; }; /** @@ -12988,36 +12988,36 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table) */ - interface Table { + interface Table { /** * The read-only **`length`** prototype property of the WebAssembly.Table object returns the length of the table, i.e., the number of elements in the table. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/length) */ - readonly length: AddressValue; + readonly length: AddressValueMap[TAddress]; /** * The **`get()`** prototype method of the WebAssembly.Table() object retrieves the element stored at a given index. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/get) */ - get(index: AddressValue): any; + get(index: AddressValueMap[TAddress]): any; /** * The **`grow()`** prototype method of the WebAssembly.Table object increases the size of the Table instance by a specified number of elements, filled with the provided value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/grow) */ - grow(delta: AddressValue, value?: any): AddressValue; + grow(delta: AddressValueMap[TAddress], value?: any): AddressValueMap[TAddress]; /** * The **`set()`** prototype method of the WebAssembly.Table object mutates a reference stored at a given index to a different value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/set) */ - set(index: AddressValue, value?: any): void; + set(index: AddressValueMap[TAddress], value?: any): void; } var Table: { prototype: Table; - new(descriptor: TableDescriptor, value?: any): Table; + new(descriptor: TableDescriptor, value?: any): Table; }; /** @@ -13033,6 +13033,11 @@ declare namespace WebAssembly { new(type: TagType): Tag; }; + interface AddressValueMap { + i32: number; + i64: bigint; + } + interface ExceptionOptions { traceStack?: boolean; } @@ -13042,10 +13047,10 @@ declare namespace WebAssembly { value: T; } - interface MemoryDescriptor { - address?: AddressType; - initial: AddressValue; - maximum?: AddressValue; + interface MemoryDescriptor { + address?: TAddress; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; shared?: boolean; } @@ -13060,11 +13065,11 @@ declare namespace WebAssembly { name: string; } - interface TableDescriptor { - address?: AddressType; + interface TableDescriptor { + address?: TAddress; element: TableKind; - initial: AddressValue; - maximum?: AddressValue; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; } interface TagType { @@ -13097,7 +13102,7 @@ declare namespace WebAssembly { type AddressValue = number; type ExportValue = Function | Global | Memory | Table; type Exports = Record; - type ImportValue = ExportValue | number; + type ImportValue = ExportValue | Memory | Table | number; type Imports = Record; type ModuleImports = Record; type ValueType = keyof ValueTypeMap; diff --git a/baselines/ts5.6/webworker.generated.d.ts b/baselines/ts5.6/webworker.generated.d.ts index 424a26382..edd7228a3 100644 --- a/baselines/ts5.6/webworker.generated.d.ts +++ b/baselines/ts5.6/webworker.generated.d.ts @@ -15041,7 +15041,7 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory) */ - interface Memory { + interface Memory { /** * The read-only **`buffer`** prototype property of the WebAssembly.Memory object returns the buffer contained in the memory. Depending on whether or not the memory was constructed with shared: true, the buffer is either an ArrayBuffer or a SharedArrayBuffer. * @@ -15053,15 +15053,15 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory/grow) */ - grow(delta: AddressValue): AddressValue; + grow(delta: AddressValueMap[TAddress]): AddressValueMap[TAddress]; toFixedLengthBuffer(): TArrayBuffer; toResizableBuffer(): TArrayBuffer; } var Memory: { prototype: Memory; - new(descriptor: MemoryDescriptor & { shared?: false }): Memory; - new(descriptor: MemoryDescriptor): Memory; + new(descriptor: MemoryDescriptor & { shared?: false }): Memory; + new(descriptor: MemoryDescriptor): Memory; }; /** @@ -15110,36 +15110,36 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table) */ - interface Table { + interface Table { /** * The read-only **`length`** prototype property of the WebAssembly.Table object returns the length of the table, i.e., the number of elements in the table. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/length) */ - readonly length: AddressValue; + readonly length: AddressValueMap[TAddress]; /** * The **`get()`** prototype method of the WebAssembly.Table() object retrieves the element stored at a given index. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/get) */ - get(index: AddressValue): any; + get(index: AddressValueMap[TAddress]): any; /** * The **`grow()`** prototype method of the WebAssembly.Table object increases the size of the Table instance by a specified number of elements, filled with the provided value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/grow) */ - grow(delta: AddressValue, value?: any): AddressValue; + grow(delta: AddressValueMap[TAddress], value?: any): AddressValueMap[TAddress]; /** * The **`set()`** prototype method of the WebAssembly.Table object mutates a reference stored at a given index to a different value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/set) */ - set(index: AddressValue, value?: any): void; + set(index: AddressValueMap[TAddress], value?: any): void; } var Table: { prototype: Table; - new(descriptor: TableDescriptor, value?: any): Table; + new(descriptor: TableDescriptor, value?: any): Table; }; /** @@ -15155,6 +15155,11 @@ declare namespace WebAssembly { new(type: TagType): Tag; }; + interface AddressValueMap { + i32: number; + i64: bigint; + } + interface ExceptionOptions { traceStack?: boolean; } @@ -15164,10 +15169,10 @@ declare namespace WebAssembly { value: T; } - interface MemoryDescriptor { - address?: AddressType; - initial: AddressValue; - maximum?: AddressValue; + interface MemoryDescriptor { + address?: TAddress; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; shared?: boolean; } @@ -15182,11 +15187,11 @@ declare namespace WebAssembly { name: string; } - interface TableDescriptor { - address?: AddressType; + interface TableDescriptor { + address?: TAddress; element: TableKind; - initial: AddressValue; - maximum?: AddressValue; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; } interface TagType { @@ -15219,7 +15224,7 @@ declare namespace WebAssembly { type AddressValue = number; type ExportValue = Function | Global | Memory | Table; type Exports = Record; - type ImportValue = ExportValue | number; + type ImportValue = ExportValue | Memory | Table | number; type Imports = Record; type ModuleImports = Record; type ValueType = keyof ValueTypeMap; diff --git a/baselines/ts5.9/audioworklet.generated.d.ts b/baselines/ts5.9/audioworklet.generated.d.ts index 32aba249f..99e4a53bf 100644 --- a/baselines/ts5.9/audioworklet.generated.d.ts +++ b/baselines/ts5.9/audioworklet.generated.d.ts @@ -1657,7 +1657,7 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory) */ - interface Memory { + interface Memory { /** * The read-only **`buffer`** prototype property of the WebAssembly.Memory object returns the buffer contained in the memory. Depending on whether or not the memory was constructed with shared: true, the buffer is either an ArrayBuffer or a SharedArrayBuffer. * @@ -1669,15 +1669,15 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory/grow) */ - grow(delta: AddressValue): AddressValue; + grow(delta: AddressValueMap[TAddress]): AddressValueMap[TAddress]; toFixedLengthBuffer(): TArrayBuffer; toResizableBuffer(): TArrayBuffer; } var Memory: { prototype: Memory; - new(descriptor: MemoryDescriptor & { shared?: false }): Memory; - new(descriptor: MemoryDescriptor): Memory; + new(descriptor: MemoryDescriptor & { shared?: false }): Memory; + new(descriptor: MemoryDescriptor): Memory; }; /** @@ -1726,36 +1726,36 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table) */ - interface Table { + interface Table { /** * The read-only **`length`** prototype property of the WebAssembly.Table object returns the length of the table, i.e., the number of elements in the table. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/length) */ - readonly length: AddressValue; + readonly length: AddressValueMap[TAddress]; /** * The **`get()`** prototype method of the WebAssembly.Table() object retrieves the element stored at a given index. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/get) */ - get(index: AddressValue): any; + get(index: AddressValueMap[TAddress]): any; /** * The **`grow()`** prototype method of the WebAssembly.Table object increases the size of the Table instance by a specified number of elements, filled with the provided value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/grow) */ - grow(delta: AddressValue, value?: any): AddressValue; + grow(delta: AddressValueMap[TAddress], value?: any): AddressValueMap[TAddress]; /** * The **`set()`** prototype method of the WebAssembly.Table object mutates a reference stored at a given index to a different value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/set) */ - set(index: AddressValue, value?: any): void; + set(index: AddressValueMap[TAddress], value?: any): void; } var Table: { prototype: Table; - new(descriptor: TableDescriptor, value?: any): Table; + new(descriptor: TableDescriptor, value?: any): Table; }; /** @@ -1771,6 +1771,11 @@ declare namespace WebAssembly { new(type: TagType): Tag; }; + interface AddressValueMap { + i32: number; + i64: bigint; + } + interface ExceptionOptions { traceStack?: boolean; } @@ -1780,10 +1785,10 @@ declare namespace WebAssembly { value: T; } - interface MemoryDescriptor { - address?: AddressType; - initial: AddressValue; - maximum?: AddressValue; + interface MemoryDescriptor { + address?: TAddress; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; shared?: boolean; } @@ -1798,11 +1803,11 @@ declare namespace WebAssembly { name: string; } - interface TableDescriptor { - address?: AddressType; + interface TableDescriptor { + address?: TAddress; element: TableKind; - initial: AddressValue; - maximum?: AddressValue; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; } interface TagType { @@ -1835,7 +1840,7 @@ declare namespace WebAssembly { type AddressValue = number; type ExportValue = Function | Global | Memory | Table; type Exports = Record; - type ImportValue = ExportValue | number; + type ImportValue = ExportValue | Memory | Table | number; type Imports = Record; type ModuleImports = Record; type ValueType = keyof ValueTypeMap; diff --git a/baselines/ts5.9/dom.generated.d.ts b/baselines/ts5.9/dom.generated.d.ts index 5947affb0..6f4f1087e 100644 --- a/baselines/ts5.9/dom.generated.d.ts +++ b/baselines/ts5.9/dom.generated.d.ts @@ -44093,7 +44093,7 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory) */ - interface Memory { + interface Memory { /** * The read-only **`buffer`** prototype property of the WebAssembly.Memory object returns the buffer contained in the memory. Depending on whether or not the memory was constructed with shared: true, the buffer is either an ArrayBuffer or a SharedArrayBuffer. * @@ -44105,15 +44105,15 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory/grow) */ - grow(delta: AddressValue): AddressValue; + grow(delta: AddressValueMap[TAddress]): AddressValueMap[TAddress]; toFixedLengthBuffer(): TArrayBuffer; toResizableBuffer(): TArrayBuffer; } var Memory: { prototype: Memory; - new(descriptor: MemoryDescriptor & { shared?: false }): Memory; - new(descriptor: MemoryDescriptor): Memory; + new(descriptor: MemoryDescriptor & { shared?: false }): Memory; + new(descriptor: MemoryDescriptor): Memory; }; /** @@ -44162,36 +44162,36 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table) */ - interface Table { + interface Table { /** * The read-only **`length`** prototype property of the WebAssembly.Table object returns the length of the table, i.e., the number of elements in the table. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/length) */ - readonly length: AddressValue; + readonly length: AddressValueMap[TAddress]; /** * The **`get()`** prototype method of the WebAssembly.Table() object retrieves the element stored at a given index. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/get) */ - get(index: AddressValue): any; + get(index: AddressValueMap[TAddress]): any; /** * The **`grow()`** prototype method of the WebAssembly.Table object increases the size of the Table instance by a specified number of elements, filled with the provided value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/grow) */ - grow(delta: AddressValue, value?: any): AddressValue; + grow(delta: AddressValueMap[TAddress], value?: any): AddressValueMap[TAddress]; /** * The **`set()`** prototype method of the WebAssembly.Table object mutates a reference stored at a given index to a different value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/set) */ - set(index: AddressValue, value?: any): void; + set(index: AddressValueMap[TAddress], value?: any): void; } var Table: { prototype: Table; - new(descriptor: TableDescriptor, value?: any): Table; + new(descriptor: TableDescriptor, value?: any): Table; }; /** @@ -44207,6 +44207,11 @@ declare namespace WebAssembly { new(type: TagType): Tag; }; + interface AddressValueMap { + i32: number; + i64: bigint; + } + interface ExceptionOptions { traceStack?: boolean; } @@ -44216,10 +44221,10 @@ declare namespace WebAssembly { value: T; } - interface MemoryDescriptor { - address?: AddressType; - initial: AddressValue; - maximum?: AddressValue; + interface MemoryDescriptor { + address?: TAddress; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; shared?: boolean; } @@ -44234,11 +44239,11 @@ declare namespace WebAssembly { name: string; } - interface TableDescriptor { - address?: AddressType; + interface TableDescriptor { + address?: TAddress; element: TableKind; - initial: AddressValue; - maximum?: AddressValue; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; } interface TagType { @@ -44271,7 +44276,7 @@ declare namespace WebAssembly { type AddressValue = number; type ExportValue = Function | Global | Memory | Table; type Exports = Record; - type ImportValue = ExportValue | number; + type ImportValue = ExportValue | Memory | Table | number; type Imports = Record; type ModuleImports = Record; type ValueType = keyof ValueTypeMap; diff --git a/baselines/ts5.9/serviceworker.generated.d.ts b/baselines/ts5.9/serviceworker.generated.d.ts index 5b2dc052f..98600009f 100644 --- a/baselines/ts5.9/serviceworker.generated.d.ts +++ b/baselines/ts5.9/serviceworker.generated.d.ts @@ -13231,7 +13231,7 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory) */ - interface Memory { + interface Memory { /** * The read-only **`buffer`** prototype property of the WebAssembly.Memory object returns the buffer contained in the memory. Depending on whether or not the memory was constructed with shared: true, the buffer is either an ArrayBuffer or a SharedArrayBuffer. * @@ -13243,15 +13243,15 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory/grow) */ - grow(delta: AddressValue): AddressValue; + grow(delta: AddressValueMap[TAddress]): AddressValueMap[TAddress]; toFixedLengthBuffer(): TArrayBuffer; toResizableBuffer(): TArrayBuffer; } var Memory: { prototype: Memory; - new(descriptor: MemoryDescriptor & { shared?: false }): Memory; - new(descriptor: MemoryDescriptor): Memory; + new(descriptor: MemoryDescriptor & { shared?: false }): Memory; + new(descriptor: MemoryDescriptor): Memory; }; /** @@ -13300,36 +13300,36 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table) */ - interface Table { + interface Table { /** * The read-only **`length`** prototype property of the WebAssembly.Table object returns the length of the table, i.e., the number of elements in the table. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/length) */ - readonly length: AddressValue; + readonly length: AddressValueMap[TAddress]; /** * The **`get()`** prototype method of the WebAssembly.Table() object retrieves the element stored at a given index. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/get) */ - get(index: AddressValue): any; + get(index: AddressValueMap[TAddress]): any; /** * The **`grow()`** prototype method of the WebAssembly.Table object increases the size of the Table instance by a specified number of elements, filled with the provided value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/grow) */ - grow(delta: AddressValue, value?: any): AddressValue; + grow(delta: AddressValueMap[TAddress], value?: any): AddressValueMap[TAddress]; /** * The **`set()`** prototype method of the WebAssembly.Table object mutates a reference stored at a given index to a different value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/set) */ - set(index: AddressValue, value?: any): void; + set(index: AddressValueMap[TAddress], value?: any): void; } var Table: { prototype: Table; - new(descriptor: TableDescriptor, value?: any): Table; + new(descriptor: TableDescriptor, value?: any): Table; }; /** @@ -13345,6 +13345,11 @@ declare namespace WebAssembly { new(type: TagType): Tag; }; + interface AddressValueMap { + i32: number; + i64: bigint; + } + interface ExceptionOptions { traceStack?: boolean; } @@ -13354,10 +13359,10 @@ declare namespace WebAssembly { value: T; } - interface MemoryDescriptor { - address?: AddressType; - initial: AddressValue; - maximum?: AddressValue; + interface MemoryDescriptor { + address?: TAddress; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; shared?: boolean; } @@ -13372,11 +13377,11 @@ declare namespace WebAssembly { name: string; } - interface TableDescriptor { - address?: AddressType; + interface TableDescriptor { + address?: TAddress; element: TableKind; - initial: AddressValue; - maximum?: AddressValue; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; } interface TagType { @@ -13409,7 +13414,7 @@ declare namespace WebAssembly { type AddressValue = number; type ExportValue = Function | Global | Memory | Table; type Exports = Record; - type ImportValue = ExportValue | number; + type ImportValue = ExportValue | Memory | Table | number; type Imports = Record; type ModuleImports = Record; type ValueType = keyof ValueTypeMap; diff --git a/baselines/ts5.9/sharedworker.generated.d.ts b/baselines/ts5.9/sharedworker.generated.d.ts index 8d22f8fbb..e2ef7e790 100644 --- a/baselines/ts5.9/sharedworker.generated.d.ts +++ b/baselines/ts5.9/sharedworker.generated.d.ts @@ -12919,7 +12919,7 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory) */ - interface Memory { + interface Memory { /** * The read-only **`buffer`** prototype property of the WebAssembly.Memory object returns the buffer contained in the memory. Depending on whether or not the memory was constructed with shared: true, the buffer is either an ArrayBuffer or a SharedArrayBuffer. * @@ -12931,15 +12931,15 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory/grow) */ - grow(delta: AddressValue): AddressValue; + grow(delta: AddressValueMap[TAddress]): AddressValueMap[TAddress]; toFixedLengthBuffer(): TArrayBuffer; toResizableBuffer(): TArrayBuffer; } var Memory: { prototype: Memory; - new(descriptor: MemoryDescriptor & { shared?: false }): Memory; - new(descriptor: MemoryDescriptor): Memory; + new(descriptor: MemoryDescriptor & { shared?: false }): Memory; + new(descriptor: MemoryDescriptor): Memory; }; /** @@ -12988,36 +12988,36 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table) */ - interface Table { + interface Table { /** * The read-only **`length`** prototype property of the WebAssembly.Table object returns the length of the table, i.e., the number of elements in the table. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/length) */ - readonly length: AddressValue; + readonly length: AddressValueMap[TAddress]; /** * The **`get()`** prototype method of the WebAssembly.Table() object retrieves the element stored at a given index. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/get) */ - get(index: AddressValue): any; + get(index: AddressValueMap[TAddress]): any; /** * The **`grow()`** prototype method of the WebAssembly.Table object increases the size of the Table instance by a specified number of elements, filled with the provided value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/grow) */ - grow(delta: AddressValue, value?: any): AddressValue; + grow(delta: AddressValueMap[TAddress], value?: any): AddressValueMap[TAddress]; /** * The **`set()`** prototype method of the WebAssembly.Table object mutates a reference stored at a given index to a different value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/set) */ - set(index: AddressValue, value?: any): void; + set(index: AddressValueMap[TAddress], value?: any): void; } var Table: { prototype: Table; - new(descriptor: TableDescriptor, value?: any): Table; + new(descriptor: TableDescriptor, value?: any): Table; }; /** @@ -13033,6 +13033,11 @@ declare namespace WebAssembly { new(type: TagType): Tag; }; + interface AddressValueMap { + i32: number; + i64: bigint; + } + interface ExceptionOptions { traceStack?: boolean; } @@ -13042,10 +13047,10 @@ declare namespace WebAssembly { value: T; } - interface MemoryDescriptor { - address?: AddressType; - initial: AddressValue; - maximum?: AddressValue; + interface MemoryDescriptor { + address?: TAddress; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; shared?: boolean; } @@ -13060,11 +13065,11 @@ declare namespace WebAssembly { name: string; } - interface TableDescriptor { - address?: AddressType; + interface TableDescriptor { + address?: TAddress; element: TableKind; - initial: AddressValue; - maximum?: AddressValue; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; } interface TagType { @@ -13097,7 +13102,7 @@ declare namespace WebAssembly { type AddressValue = number; type ExportValue = Function | Global | Memory | Table; type Exports = Record; - type ImportValue = ExportValue | number; + type ImportValue = ExportValue | Memory | Table | number; type Imports = Record; type ModuleImports = Record; type ValueType = keyof ValueTypeMap; diff --git a/baselines/ts5.9/webworker.generated.d.ts b/baselines/ts5.9/webworker.generated.d.ts index 3157a7243..7a80a38d8 100644 --- a/baselines/ts5.9/webworker.generated.d.ts +++ b/baselines/ts5.9/webworker.generated.d.ts @@ -15041,7 +15041,7 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory) */ - interface Memory { + interface Memory { /** * The read-only **`buffer`** prototype property of the WebAssembly.Memory object returns the buffer contained in the memory. Depending on whether or not the memory was constructed with shared: true, the buffer is either an ArrayBuffer or a SharedArrayBuffer. * @@ -15053,15 +15053,15 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory/grow) */ - grow(delta: AddressValue): AddressValue; + grow(delta: AddressValueMap[TAddress]): AddressValueMap[TAddress]; toFixedLengthBuffer(): TArrayBuffer; toResizableBuffer(): TArrayBuffer; } var Memory: { prototype: Memory; - new(descriptor: MemoryDescriptor & { shared?: false }): Memory; - new(descriptor: MemoryDescriptor): Memory; + new(descriptor: MemoryDescriptor & { shared?: false }): Memory; + new(descriptor: MemoryDescriptor): Memory; }; /** @@ -15110,36 +15110,36 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table) */ - interface Table { + interface Table { /** * The read-only **`length`** prototype property of the WebAssembly.Table object returns the length of the table, i.e., the number of elements in the table. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/length) */ - readonly length: AddressValue; + readonly length: AddressValueMap[TAddress]; /** * The **`get()`** prototype method of the WebAssembly.Table() object retrieves the element stored at a given index. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/get) */ - get(index: AddressValue): any; + get(index: AddressValueMap[TAddress]): any; /** * The **`grow()`** prototype method of the WebAssembly.Table object increases the size of the Table instance by a specified number of elements, filled with the provided value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/grow) */ - grow(delta: AddressValue, value?: any): AddressValue; + grow(delta: AddressValueMap[TAddress], value?: any): AddressValueMap[TAddress]; /** * The **`set()`** prototype method of the WebAssembly.Table object mutates a reference stored at a given index to a different value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/set) */ - set(index: AddressValue, value?: any): void; + set(index: AddressValueMap[TAddress], value?: any): void; } var Table: { prototype: Table; - new(descriptor: TableDescriptor, value?: any): Table; + new(descriptor: TableDescriptor, value?: any): Table; }; /** @@ -15155,6 +15155,11 @@ declare namespace WebAssembly { new(type: TagType): Tag; }; + interface AddressValueMap { + i32: number; + i64: bigint; + } + interface ExceptionOptions { traceStack?: boolean; } @@ -15164,10 +15169,10 @@ declare namespace WebAssembly { value: T; } - interface MemoryDescriptor { - address?: AddressType; - initial: AddressValue; - maximum?: AddressValue; + interface MemoryDescriptor { + address?: TAddress; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; shared?: boolean; } @@ -15182,11 +15187,11 @@ declare namespace WebAssembly { name: string; } - interface TableDescriptor { - address?: AddressType; + interface TableDescriptor { + address?: TAddress; element: TableKind; - initial: AddressValue; - maximum?: AddressValue; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; } interface TagType { @@ -15219,7 +15224,7 @@ declare namespace WebAssembly { type AddressValue = number; type ExportValue = Function | Global | Memory | Table; type Exports = Record; - type ImportValue = ExportValue | number; + type ImportValue = ExportValue | Memory | Table | number; type Imports = Record; type ModuleImports = Record; type ValueType = keyof ValueTypeMap; diff --git a/baselines/webworker.generated.d.ts b/baselines/webworker.generated.d.ts index 78cd5d7b9..95b91d839 100644 --- a/baselines/webworker.generated.d.ts +++ b/baselines/webworker.generated.d.ts @@ -15044,7 +15044,7 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory) */ - interface Memory { + interface Memory { /** * The read-only **`buffer`** prototype property of the WebAssembly.Memory object returns the buffer contained in the memory. Depending on whether or not the memory was constructed with shared: true, the buffer is either an ArrayBuffer or a SharedArrayBuffer. * @@ -15056,15 +15056,15 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Memory/grow) */ - grow(delta: AddressValue): AddressValue; + grow(delta: AddressValueMap[TAddress]): AddressValueMap[TAddress]; toFixedLengthBuffer(): TArrayBuffer; toResizableBuffer(): TArrayBuffer; } var Memory: { prototype: Memory; - new(descriptor: MemoryDescriptor & { shared?: false }): Memory; - new(descriptor: MemoryDescriptor): Memory; + new(descriptor: MemoryDescriptor & { shared?: false }): Memory; + new(descriptor: MemoryDescriptor): Memory; }; /** @@ -15113,36 +15113,36 @@ declare namespace WebAssembly { * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table) */ - interface Table { + interface Table { /** * The read-only **`length`** prototype property of the WebAssembly.Table object returns the length of the table, i.e., the number of elements in the table. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/length) */ - readonly length: AddressValue; + readonly length: AddressValueMap[TAddress]; /** * The **`get()`** prototype method of the WebAssembly.Table() object retrieves the element stored at a given index. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/get) */ - get(index: AddressValue): any; + get(index: AddressValueMap[TAddress]): any; /** * The **`grow()`** prototype method of the WebAssembly.Table object increases the size of the Table instance by a specified number of elements, filled with the provided value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/grow) */ - grow(delta: AddressValue, value?: any): AddressValue; + grow(delta: AddressValueMap[TAddress], value?: any): AddressValueMap[TAddress]; /** * The **`set()`** prototype method of the WebAssembly.Table object mutates a reference stored at a given index to a different value. * * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Table/set) */ - set(index: AddressValue, value?: any): void; + set(index: AddressValueMap[TAddress], value?: any): void; } var Table: { prototype: Table; - new(descriptor: TableDescriptor, value?: any): Table; + new(descriptor: TableDescriptor, value?: any): Table; }; /** @@ -15158,6 +15158,11 @@ declare namespace WebAssembly { new(type: TagType): Tag; }; + interface AddressValueMap { + i32: number; + i64: bigint; + } + interface ExceptionOptions { traceStack?: boolean; } @@ -15167,10 +15172,10 @@ declare namespace WebAssembly { value: T; } - interface MemoryDescriptor { - address?: AddressType; - initial: AddressValue; - maximum?: AddressValue; + interface MemoryDescriptor { + address?: TAddress; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; shared?: boolean; } @@ -15185,11 +15190,11 @@ declare namespace WebAssembly { name: string; } - interface TableDescriptor { - address?: AddressType; + interface TableDescriptor { + address?: TAddress; element: TableKind; - initial: AddressValue; - maximum?: AddressValue; + initial: AddressValueMap[TAddress]; + maximum?: AddressValueMap[TAddress]; } interface TagType { @@ -15222,7 +15227,7 @@ declare namespace WebAssembly { type AddressValue = number; type ExportValue = Function | Global | Memory | Table; type Exports = Record; - type ImportValue = ExportValue | number; + type ImportValue = ExportValue | Memory | Table | number; type Imports = Record; type ModuleImports = Record; type ValueType = keyof ValueTypeMap; diff --git a/inputfiles/knownTypes.json b/inputfiles/knownTypes.json index 3abf26035..b2f399288 100644 --- a/inputfiles/knownTypes.json +++ b/inputfiles/knownTypes.json @@ -1,5 +1,6 @@ { "Window": [ + "AddressValueMap", "AesCbcParams", "AesCtrParams", "AesDerivedKeyParams", @@ -61,6 +62,7 @@ "VideoFacingModeEnum" ], "Worker": [ + "AddressValueMap", "AesCbcParams", "AesCtrParams", "AesDerivedKeyParams", @@ -88,6 +90,7 @@ "ValueTypeMap" ], "Worklet": [ + "AddressValueMap", "ValueTypeMap" ] } diff --git a/inputfiles/overridingTypes.jsonc b/inputfiles/overridingTypes.jsonc index 433134cb6..fcc068e21 100644 --- a/inputfiles/overridingTypes.jsonc +++ b/inputfiles/overridingTypes.jsonc @@ -2838,12 +2838,17 @@ "name": "TArrayBuffer", "extends": "ArrayBufferLike", "default": "ArrayBufferLike" + }, + { + "name": "TAddress", + "extends": "AddressType", + "default": "\"i32\"" } ], "constructor": { "overrideSignatures": [ - "new(descriptor: MemoryDescriptor & { shared?: false }): Memory", - "new(descriptor: MemoryDescriptor): Memory" + "new(descriptor: MemoryDescriptor & { shared?: false }): Memory", + "new(descriptor: MemoryDescriptor): Memory" ] }, "properties": { @@ -2855,6 +2860,11 @@ }, "methods": { "method": { + "grow": { + "overrideSignatures": [ + "grow(delta: AddressValueMap[TAddress]): AddressValueMap[TAddress]" + ] + }, "toFixedLengthBuffer": { "overrideSignatures": [ "toFixedLengthBuffer(): TArrayBuffer" @@ -2868,6 +2878,49 @@ } } }, + // 64-bit tables (memory64) take and return bigint addresses + // https://webassembly.github.io/spec/js-api/#tables + "Table": { + "name": "Table", + "typeParameters": [ + { + "name": "TAddress", + "extends": "AddressType", + "default": "\"i32\"" + } + ], + "constructor": { + "overrideSignatures": [ + "new(descriptor: TableDescriptor, value?: any): Table" + ] + }, + "properties": { + "property": { + "length": { + "overrideType": "AddressValueMap[TAddress]" + } + } + }, + "methods": { + "method": { + "get": { + "overrideSignatures": [ + "get(index: AddressValueMap[TAddress]): any" + ] + }, + "grow": { + "overrideSignatures": [ + "grow(delta: AddressValueMap[TAddress], value?: any): AddressValueMap[TAddress]" + ] + }, + "set": { + "overrideSignatures": [ + "set(index: AddressValueMap[TAddress], value?: any): void" + ] + } + } + } + }, // https://github.com/w3c/media-source/pull/282, but not supported anywhere yet "MediaSource": { @@ -3273,10 +3326,50 @@ "legacyNamespace": "WebAssembly" }, "MemoryDescriptor": { - "legacyNamespace": "WebAssembly" + "legacyNamespace": "WebAssembly", + "typeParameters": [ + { + "name": "TAddress", + "extends": "AddressType", + "default": "\"i32\"" + } + ], + "members": { + "member": { + "address": { + "overrideType": "TAddress" + }, + "initial": { + "overrideType": "AddressValueMap[TAddress]" + }, + "maximum": { + "overrideType": "AddressValueMap[TAddress]" + } + } + } }, "TableDescriptor": { - "legacyNamespace": "WebAssembly" + "legacyNamespace": "WebAssembly", + "typeParameters": [ + { + "name": "TAddress", + "extends": "AddressType", + "default": "\"i32\"" + } + ], + "members": { + "member": { + "address": { + "overrideType": "TAddress" + }, + "initial": { + "overrideType": "AddressValueMap[TAddress]" + }, + "maximum": { + "overrideType": "AddressValueMap[TAddress]" + } + } + } }, "GlobalDescriptor": { "legacyNamespace": "WebAssembly", diff --git a/inputfiles/patches/webassembly.kdl b/inputfiles/patches/webassembly.kdl index c3adceb31..5ef64ac3e 100644 --- a/inputfiles/patches/webassembly.kdl +++ b/inputfiles/patches/webassembly.kdl @@ -12,11 +12,19 @@ dictionary ValueTypeMap legacyNamespace=WebAssembly { member v128 required=#true overrideType=never } +// Maps an address type to the values it takes: 64-bit memories and tables use bigint +// https://webassembly.github.io/spec/js-api/#addressvaluetou64 +dictionary AddressValueMap legacyNamespace=WebAssembly { + member i32 required=#true type=long + member i64 required=#true type=bigint +} + dictionary MemoryDescriptor { member shared type=boolean } -typedef ImportValue legacyNamespace=WebAssembly { +// 64-bit memories and tables can be imported too +typedef ImportValue legacyNamespace=WebAssembly overrideType="ExportValue | Memory | Table | number" { type ExportValue type long } diff --git a/unittests/files/webassemblyAddress.ts b/unittests/files/webassemblyAddress.ts new file mode 100644 index 000000000..be028f446 --- /dev/null +++ b/unittests/files/webassemblyAddress.ts @@ -0,0 +1,180 @@ +function assertType(_x: T) {} + +type Equals = + (() => T extends A ? 1 : 2) extends () => T extends B ? 1 : 2 + ? true + : false; +declare function assertExact(): void; + +declare const addressType: WebAssembly.AddressType; + +function testMemory32() { + // 32-bit memories keep using numbers, with or without `address`. + const memory = new WebAssembly.Memory({ initial: 1, maximum: 2 }); + assertExact, number>>(); + assertType(memory.grow(1) + 1); + assertExact>(); + + const explicit = new WebAssembly.Memory({ address: "i32", initial: 1 }); + assertExact, number>>(); + + // A plain `WebAssembly.Memory` is a 32-bit memory. + const plain: WebAssembly.Memory = memory; + assertType(plain.grow(1) + 1); + + // @ts-expect-error A 32-bit memory takes numbers. + new WebAssembly.Memory({ initial: 1n }); + // @ts-expect-error A 32-bit memory takes numbers. + new WebAssembly.Memory({ address: "i32", initial: 1n }); + // @ts-expect-error A 32-bit memory grows by a number. + memory.grow(1n); +} + +function testMemory64() { + const memory = new WebAssembly.Memory({ + address: "i64", + initial: 1n, + maximum: 2n, + }); + assertExact, bigint>>(); + assertType(memory.grow(1n)); + assertExact>(); + + // @ts-expect-error A 64-bit memory takes bigints. + new WebAssembly.Memory({ address: "i64", initial: 1 }); + // @ts-expect-error A 64-bit memory takes bigints. + new WebAssembly.Memory({ address: "i64", initial: 1n, maximum: 2 }); + // @ts-expect-error A 64-bit memory grows by a bigint. + memory.grow(1); + + // A descriptor that is not inlined keeps the same rules. + const descriptor = { address: "i64" as const, initial: 1n }; + const fromVariable = new WebAssembly.Memory(descriptor); + assertExact, bigint>>(); + assertExact>(); + + const typedDescriptor: WebAssembly.MemoryDescriptor<"i64"> = { + address: "i64", + initial: 1n, + }; + const fromTypedDescriptor = new WebAssembly.Memory(typedDescriptor); + assertExact, bigint>>(); + + // @ts-expect-error A 64-bit memory is not a plain (32-bit) `WebAssembly.Memory`. + const plain: WebAssembly.Memory = memory; + assertType(plain); +} + +function testSharedMemory64() { + const memory = new WebAssembly.Memory({ + address: "i64", + initial: 1n, + maximum: 2n, + shared: true, + }); + assertExact, bigint>>(); + assertExact>(); + + const shared32 = new WebAssembly.Memory({ + initial: 1, + maximum: 2, + shared: true, + }); + assertExact, number>>(); + assertExact>(); +} + +function testTable32() { + const table = new WebAssembly.Table({ element: "anyfunc", initial: 1 }); + assertExact>(); + assertExact, number>>(); + assertType(table.length + 1); + table.get(0); + table.set(0, null); + + // A plain `WebAssembly.Table` is a 32-bit table. + const plain: WebAssembly.Table = table; + assertType(plain.length + 1); + + // A descriptor typed as `TableDescriptor` is a 32-bit one. + const typedDescriptor: WebAssembly.TableDescriptor = { + element: "externref", + initial: 1, + }; + const fromTypedDescriptor = new WebAssembly.Table(typedDescriptor); + assertExact>(); + + // @ts-expect-error A 32-bit table takes numbers. + new WebAssembly.Table({ element: "anyfunc", initial: 1n }); + // @ts-expect-error A 32-bit table is indexed by numbers. + table.get(0n); +} + +function testTable64() { + const table = new WebAssembly.Table({ + address: "i64", + element: "anyfunc", + initial: 1n, + maximum: 2n, + }); + assertExact>(); + assertExact, bigint>>(); + assertType(table.grow(1n)); + table.get(0n); + table.set(0n, null); + + // @ts-expect-error A 64-bit table takes bigints. + new WebAssembly.Table({ address: "i64", element: "anyfunc", initial: 1 }); + // @ts-expect-error A 64-bit table is indexed by bigints. + table.get(0); + // @ts-expect-error A 64-bit table is indexed by bigints. + table.set(0, null); + // @ts-expect-error A 64-bit table grows by a bigint. + table.grow(1); + + // A descriptor that is not inlined keeps the same rules. + const descriptor = { + address: "i64" as const, + element: "externref" as const, + initial: 1n, + }; + const fromVariable = new WebAssembly.Table(descriptor); + assertExact>(); +} + +function testUnknownAddressType() { + // When `address` is not known statically, the values can be either. + const memory = new WebAssembly.Memory({ address: addressType, initial: 1 }); + assertExact, number | bigint>>(); + + const table = new WebAssembly.Table({ + address: addressType, + element: "anyfunc", + initial: 1, + }); + assertExact>(); +} + +function testImports() { + const memory64 = new WebAssembly.Memory({ address: "i64", initial: 1n }); + const table64 = new WebAssembly.Table({ + address: "i64", + element: "anyfunc", + initial: 1n, + }); + const memory32 = new WebAssembly.Memory({ initial: 1 }); + const table32 = new WebAssembly.Table({ element: "anyfunc", initial: 1 }); + + // 64-bit memories and tables can be imported, like 32-bit ones. + const imports: WebAssembly.Imports = { + env: { memory64, table64, memory32, table32 }, + }; + assertType(imports); + assertType(memory64); + assertType(table64); + + // Exports keep their 32-bit types. + const exported: WebAssembly.ExportValue = memory32; + assertType(exported); + assertType(table32); +}