From 9bcbec3ba1f93ccab9ead0568560695e0dd9aee8 Mon Sep 17 00:00:00 2001 From: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> Date: Fri, 4 Dec 2026 18:34:02 +0000 Subject: [PATCH 1/3] Initial plan From b3e347965342f550bf93eba98089b6dcc429e36a Mon Sep 17 00:00:00 2001 From: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> Date: Fri, 4 Dec 2026 18:41:56 +0000 Subject: [PATCH 2/3] Add tests for WebAssembly JS Promise Integration APIs Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- .../webAssemblyPromiseIntegration.errors.txt | 74 +++++++++ .../compiler/webAssemblyPromiseIntegration.js | 68 ++++++++ .../webAssemblyPromiseIntegration.symbols | 107 +++++++++++++ .../webAssemblyPromiseIntegration.types | 148 ++++++++++++++++++ ...mblyPromiseIntegrationWebworker.errors.txt | 27 ++++ .../webAssemblyPromiseIntegrationWebworker.js | 28 ++++ ...ssemblyPromiseIntegrationWebworker.symbols | 47 ++++++ ...bAssemblyPromiseIntegrationWebworker.types | 67 ++++++++ .../compiler/webAssemblyPromiseIntegration.ts | 38 +++++ .../webAssemblyPromiseIntegrationWebworker.ts | 15 ++ 10 files changed, 619 insertions(+) create mode 100644 tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegration.errors.txt create mode 100644 tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegration.js create mode 100644 tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegration.symbols create mode 100644 tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegration.types create mode 100644 tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegrationWebworker.errors.txt create mode 100644 tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegrationWebworker.js create mode 100644 tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegrationWebworker.symbols create mode 100644 tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegrationWebworker.types create mode 100644 tsc/testdata/tests/cases/compiler/webAssemblyPromiseIntegration.ts create mode 100644 tsc/testdata/tests/cases/compiler/webAssemblyPromiseIntegrationWebworker.ts diff --git a/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegration.errors.txt b/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegration.errors.txt new file mode 100644 index 0000000000000..22ab54eeeb788 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegration.errors.txt @@ -0,0 +1,74 @@ +webAssemblyPromiseIntegration.ts(5,31): error TS2694: Namespace 'WebAssembly' has no exported member 'Suspending'. +webAssemblyPromiseIntegration.ts(5,60): error TS2339: Property 'Suspending' does not exist on type 'typeof WebAssembly'. +webAssemblyPromiseIntegration.ts(13,39): error TS2339: Property 'promising' does not exist on type 'typeof WebAssembly'. +webAssemblyPromiseIntegration.ts(20,32): error TS2339: Property 'Suspending' does not exist on type 'typeof WebAssembly'. +webAssemblyPromiseIntegration.ts(25,34): error TS2339: Property 'SuspendError' does not exist on type 'typeof WebAssembly'. +webAssemblyPromiseIntegration.ts(26,15): error TS2322: Type 'unknown' is not assignable to type 'Error'. +webAssemblyPromiseIntegration.ts(30,25): error TS2694: Namespace 'WebAssembly' has no exported member 'SuspendError'. +webAssemblyPromiseIntegration.ts(30,56): error TS2339: Property 'SuspendError' does not exist on type 'typeof WebAssembly'. +webAssemblyPromiseIntegration.ts(31,25): error TS2694: Namespace 'WebAssembly' has no exported member 'SuspendError'. +webAssemblyPromiseIntegration.ts(31,52): error TS2339: Property 'SuspendError' does not exist on type 'typeof WebAssembly'. +webAssemblyPromiseIntegration.ts(33,17): error TS2339: Property 'Suspending' does not exist on type 'typeof WebAssembly'. +webAssemblyPromiseIntegration.ts(34,13): error TS2339: Property 'promising' does not exist on type 'typeof WebAssembly'. + + +==== webAssemblyPromiseIntegration.ts (12 errors) ==== + function someAsyncFunction() { + return fetch("https://example.com").then(result => result.status); + } + + const suspending: WebAssembly.Suspending = new WebAssembly.Suspending(someAsyncFunction); + ~~~~~~~~~~ +!!! error TS2694: Namespace 'WebAssembly' has no exported member 'Suspending'. + ~~~~~~~~~~ +!!! error TS2339: Property 'Suspending' does not exist on type 'typeof WebAssembly'. + + const importObj = { + someAsyncFunction: suspending, + }; + + async function main() { + const { instance } = await WebAssembly.instantiateStreaming(fetch("module.wasm"), { importObj }); + const run: Function = WebAssembly.promising(instance.exports.run as Function); + ~~~~~~~~~ +!!! error TS2339: Property 'promising' does not exist on type 'typeof WebAssembly'. + await run(); + } + + const imports: WebAssembly.Imports = { + env: { + sync: () => 0, + async: new WebAssembly.Suspending(async () => 0), + ~~~~~~~~~~ +!!! error TS2339: Property 'Suspending' does not exist on type 'typeof WebAssembly'. + }, + }; + + function handle(e: unknown) { + if (e instanceof WebAssembly.SuspendError) { + ~~~~~~~~~~~~ +!!! error TS2339: Property 'SuspendError' does not exist on type 'typeof WebAssembly'. + const err: Error = e; + ~~~ +!!! error TS2322: Type 'unknown' is not assignable to type 'Error'. + } + } + + const err1: WebAssembly.SuspendError = new WebAssembly.SuspendError("message"); + ~~~~~~~~~~~~ +!!! error TS2694: Namespace 'WebAssembly' has no exported member 'SuspendError'. + ~~~~~~~~~~~~ +!!! error TS2339: Property 'SuspendError' does not exist on type 'typeof WebAssembly'. + const err2: WebAssembly.SuspendError = WebAssembly.SuspendError(); + ~~~~~~~~~~~~ +!!! error TS2694: Namespace 'WebAssembly' has no exported member 'SuspendError'. + ~~~~~~~~~~~~ +!!! error TS2339: Property 'SuspendError' does not exist on type 'typeof WebAssembly'. + + new WebAssembly.Suspending(42); // error + ~~~~~~~~~~ +!!! error TS2339: Property 'Suspending' does not exist on type 'typeof WebAssembly'. + WebAssembly.promising("not a function"); // error + ~~~~~~~~~ +!!! error TS2339: Property 'promising' does not exist on type 'typeof WebAssembly'. + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegration.js b/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegration.js new file mode 100644 index 0000000000000..b5f2f53e2d70c --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegration.js @@ -0,0 +1,68 @@ +//// [tests/cases/compiler/webAssemblyPromiseIntegration.ts] //// + +//// [webAssemblyPromiseIntegration.ts] +function someAsyncFunction() { + return fetch("https://example.com").then(result => result.status); +} + +const suspending: WebAssembly.Suspending = new WebAssembly.Suspending(someAsyncFunction); + +const importObj = { + someAsyncFunction: suspending, +}; + +async function main() { + const { instance } = await WebAssembly.instantiateStreaming(fetch("module.wasm"), { importObj }); + const run: Function = WebAssembly.promising(instance.exports.run as Function); + await run(); +} + +const imports: WebAssembly.Imports = { + env: { + sync: () => 0, + async: new WebAssembly.Suspending(async () => 0), + }, +}; + +function handle(e: unknown) { + if (e instanceof WebAssembly.SuspendError) { + const err: Error = e; + } +} + +const err1: WebAssembly.SuspendError = new WebAssembly.SuspendError("message"); +const err2: WebAssembly.SuspendError = WebAssembly.SuspendError(); + +new WebAssembly.Suspending(42); // error +WebAssembly.promising("not a function"); // error + + +//// [webAssemblyPromiseIntegration.js] +"use strict"; +function someAsyncFunction() { + return fetch("https://example.com").then(result => result.status); +} +const suspending = new WebAssembly.Suspending(someAsyncFunction); +const importObj = { + someAsyncFunction: suspending, +}; +async function main() { + const { instance } = await WebAssembly.instantiateStreaming(fetch("module.wasm"), { importObj }); + const run = WebAssembly.promising(instance.exports.run); + await run(); +} +const imports = { + env: { + sync: () => 0, + async: new WebAssembly.Suspending(async () => 0), + }, +}; +function handle(e) { + if (e instanceof WebAssembly.SuspendError) { + const err = e; + } +} +const err1 = new WebAssembly.SuspendError("message"); +const err2 = WebAssembly.SuspendError(); +new WebAssembly.Suspending(42); // error +WebAssembly.promising("not a function"); // error diff --git a/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegration.symbols b/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegration.symbols new file mode 100644 index 0000000000000..c63938ca02421 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegration.symbols @@ -0,0 +1,107 @@ +//// [tests/cases/compiler/webAssemblyPromiseIntegration.ts] //// + +=== webAssemblyPromiseIntegration.ts === +function someAsyncFunction() { +>someAsyncFunction : Symbol(someAsyncFunction, Decl(webAssemblyPromiseIntegration.ts, 0, 0)) + + return fetch("https://example.com").then(result => result.status); +>fetch("https://example.com").then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>fetch : Symbol(fetch, Decl(lib.dom.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>result : Symbol(result, Decl(webAssemblyPromiseIntegration.ts, 1, 45)) +>result.status : Symbol(Response.status, Decl(lib.dom.d.ts, --, --)) +>result : Symbol(result, Decl(webAssemblyPromiseIntegration.ts, 1, 45)) +>status : Symbol(Response.status, Decl(lib.dom.d.ts, --, --)) +} + +const suspending: WebAssembly.Suspending = new WebAssembly.Suspending(someAsyncFunction); +>suspending : Symbol(suspending, Decl(webAssemblyPromiseIntegration.ts, 4, 5)) +>WebAssembly : Symbol(WebAssembly, Decl(lib.dom.d.ts, --, --)) +>Suspending : Symbol(WebAssembly.Suspending) +>WebAssembly : Symbol(WebAssembly, Decl(lib.dom.d.ts, --, --)) +>someAsyncFunction : Symbol(someAsyncFunction, Decl(webAssemblyPromiseIntegration.ts, 0, 0)) + +const importObj = { +>importObj : Symbol(importObj, Decl(webAssemblyPromiseIntegration.ts, 6, 5)) + + someAsyncFunction: suspending, +>someAsyncFunction : Symbol(someAsyncFunction, Decl(webAssemblyPromiseIntegration.ts, 6, 19)) +>suspending : Symbol(suspending, Decl(webAssemblyPromiseIntegration.ts, 4, 5)) + +}; + +async function main() { +>main : Symbol(main, Decl(webAssemblyPromiseIntegration.ts, 8, 2)) + + const { instance } = await WebAssembly.instantiateStreaming(fetch("module.wasm"), { importObj }); +>instance : Symbol(instance, Decl(webAssemblyPromiseIntegration.ts, 11, 11)) +>WebAssembly.instantiateStreaming : Symbol(WebAssembly.instantiateStreaming, Decl(lib.dom.d.ts, --, --)) +>WebAssembly : Symbol(WebAssembly, Decl(lib.dom.d.ts, --, --)) +>instantiateStreaming : Symbol(WebAssembly.instantiateStreaming, Decl(lib.dom.d.ts, --, --)) +>fetch : Symbol(fetch, Decl(lib.dom.d.ts, --, --)) +>importObj : Symbol(importObj, Decl(webAssemblyPromiseIntegration.ts, 11, 87)) + + const run: Function = WebAssembly.promising(instance.exports.run as Function); +>run : Symbol(run, Decl(webAssemblyPromiseIntegration.ts, 12, 9)) +>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.decorators.d.ts, --, --)) +>WebAssembly : Symbol(WebAssembly, Decl(lib.dom.d.ts, --, --)) +>instance.exports : Symbol(WebAssembly.Instance.exports, Decl(lib.dom.d.ts, --, --)) +>instance : Symbol(instance, Decl(webAssemblyPromiseIntegration.ts, 11, 11)) +>exports : Symbol(WebAssembly.Instance.exports, Decl(lib.dom.d.ts, --, --)) +>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.decorators.d.ts, --, --)) + + await run(); +>run : Symbol(run, Decl(webAssemblyPromiseIntegration.ts, 12, 9)) +} + +const imports: WebAssembly.Imports = { +>imports : Symbol(imports, Decl(webAssemblyPromiseIntegration.ts, 16, 5)) +>WebAssembly : Symbol(WebAssembly, Decl(lib.dom.d.ts, --, --)) +>Imports : Symbol(WebAssembly.Imports, Decl(lib.dom.d.ts, --, --)) + + env: { +>env : Symbol(env, Decl(webAssemblyPromiseIntegration.ts, 16, 38)) + + sync: () => 0, +>sync : Symbol(sync, Decl(webAssemblyPromiseIntegration.ts, 17, 10)) + + async: new WebAssembly.Suspending(async () => 0), +>async : Symbol(async, Decl(webAssemblyPromiseIntegration.ts, 18, 22)) +>WebAssembly : Symbol(WebAssembly, Decl(lib.dom.d.ts, --, --)) + + }, +}; + +function handle(e: unknown) { +>handle : Symbol(handle, Decl(webAssemblyPromiseIntegration.ts, 21, 2)) +>e : Symbol(e, Decl(webAssemblyPromiseIntegration.ts, 23, 16)) + + if (e instanceof WebAssembly.SuspendError) { +>e : Symbol(e, Decl(webAssemblyPromiseIntegration.ts, 23, 16)) +>WebAssembly : Symbol(WebAssembly, Decl(lib.dom.d.ts, --, --)) + + const err: Error = e; +>err : Symbol(err, Decl(webAssemblyPromiseIntegration.ts, 25, 13)) +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --)) +>e : Symbol(e, Decl(webAssemblyPromiseIntegration.ts, 23, 16)) + } +} + +const err1: WebAssembly.SuspendError = new WebAssembly.SuspendError("message"); +>err1 : Symbol(err1, Decl(webAssemblyPromiseIntegration.ts, 29, 5)) +>WebAssembly : Symbol(WebAssembly, Decl(lib.dom.d.ts, --, --)) +>SuspendError : Symbol(WebAssembly.SuspendError) +>WebAssembly : Symbol(WebAssembly, Decl(lib.dom.d.ts, --, --)) + +const err2: WebAssembly.SuspendError = WebAssembly.SuspendError(); +>err2 : Symbol(err2, Decl(webAssemblyPromiseIntegration.ts, 30, 5)) +>WebAssembly : Symbol(WebAssembly, Decl(lib.dom.d.ts, --, --)) +>SuspendError : Symbol(WebAssembly.SuspendError) +>WebAssembly : Symbol(WebAssembly, Decl(lib.dom.d.ts, --, --)) + +new WebAssembly.Suspending(42); // error +>WebAssembly : Symbol(WebAssembly, Decl(lib.dom.d.ts, --, --)) + +WebAssembly.promising("not a function"); // error +>WebAssembly : Symbol(WebAssembly, Decl(lib.dom.d.ts, --, --)) + diff --git a/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegration.types b/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegration.types new file mode 100644 index 0000000000000..3a13d69b16d1e --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegration.types @@ -0,0 +1,148 @@ +//// [tests/cases/compiler/webAssemblyPromiseIntegration.ts] //// + +=== webAssemblyPromiseIntegration.ts === +function someAsyncFunction() { +>someAsyncFunction : () => Promise + + return fetch("https://example.com").then(result => result.status); +>fetch("https://example.com").then(result => result.status) : Promise +>fetch("https://example.com").then : (onfulfilled?: ((value: Response) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>fetch("https://example.com") : Promise +>fetch : (input: RequestInfo | URL, init?: RequestInit) => Promise +>"https://example.com" : "https://example.com" +>then : (onfulfilled?: ((value: Response) => TResult1 | PromiseLike) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null | undefined) => Promise +>result => result.status : (result: Response) => number +>result : Response +>result.status : number +>result : Response +>status : number +} + +const suspending: WebAssembly.Suspending = new WebAssembly.Suspending(someAsyncFunction); +>suspending : WebAssembly.Suspending +>WebAssembly : any +>new WebAssembly.Suspending(someAsyncFunction) : any +>WebAssembly.Suspending : any +>WebAssembly : typeof WebAssembly +>Suspending : any +>someAsyncFunction : () => Promise + +const importObj = { +>importObj : { someAsyncFunction: WebAssembly.Suspending; } +>{ someAsyncFunction: suspending,} : { someAsyncFunction: WebAssembly.Suspending; } + + someAsyncFunction: suspending, +>someAsyncFunction : WebAssembly.Suspending +>suspending : WebAssembly.Suspending + +}; + +async function main() { +>main : () => Promise + + const { instance } = await WebAssembly.instantiateStreaming(fetch("module.wasm"), { importObj }); +>instance : WebAssembly.Instance +>await WebAssembly.instantiateStreaming(fetch("module.wasm"), { importObj }) : WebAssembly.WebAssemblyInstantiatedSource +>WebAssembly.instantiateStreaming(fetch("module.wasm"), { importObj }) : Promise +>WebAssembly.instantiateStreaming : (source: Response | PromiseLike, importObject?: WebAssembly.Imports, options?: WebAssembly.WebAssemblyCompileOptions) => Promise +>WebAssembly : typeof WebAssembly +>instantiateStreaming : (source: Response | PromiseLike, importObject?: WebAssembly.Imports, options?: WebAssembly.WebAssemblyCompileOptions) => Promise +>fetch("module.wasm") : Promise +>fetch : (input: RequestInfo | URL, init?: RequestInit) => Promise +>"module.wasm" : "module.wasm" +>{ importObj } : { importObj: { someAsyncFunction: WebAssembly.Suspending; }; } +>importObj : { someAsyncFunction: WebAssembly.Suspending; } + + const run: Function = WebAssembly.promising(instance.exports.run as Function); +>run : Function +>WebAssembly.promising(instance.exports.run as Function) : any +>WebAssembly.promising : any +>WebAssembly : typeof WebAssembly +>promising : any +>instance.exports.run as Function : Function +>instance.exports.run : WebAssembly.ExportValue +>instance.exports : WebAssembly.Exports +>instance : WebAssembly.Instance +>exports : WebAssembly.Exports +>run : WebAssembly.ExportValue + + await run(); +>await run() : any +>run() : any +>run : Function +} + +const imports: WebAssembly.Imports = { +>imports : WebAssembly.Imports +>WebAssembly : any +>{ env: { sync: () => 0, async: new WebAssembly.Suspending(async () => 0), },} : { env: { sync: () => number; async: any; }; } + + env: { +>env : { sync: () => number; async: any; } +>{ sync: () => 0, async: new WebAssembly.Suspending(async () => 0), } : { sync: () => number; async: any; } + + sync: () => 0, +>sync : () => number +>() => 0 : () => number +>0 : 0 + + async: new WebAssembly.Suspending(async () => 0), +>async : any +>new WebAssembly.Suspending(async () => 0) : any +>WebAssembly.Suspending : any +>WebAssembly : typeof WebAssembly +>Suspending : any +>async () => 0 : () => Promise +>0 : 0 + + }, +}; + +function handle(e: unknown) { +>handle : (e: unknown) => void +>e : unknown + + if (e instanceof WebAssembly.SuspendError) { +>e instanceof WebAssembly.SuspendError : boolean +>e : unknown +>WebAssembly.SuspendError : any +>WebAssembly : typeof WebAssembly +>SuspendError : any + + const err: Error = e; +>err : Error +>e : unknown + } +} + +const err1: WebAssembly.SuspendError = new WebAssembly.SuspendError("message"); +>err1 : WebAssembly.SuspendError +>WebAssembly : any +>new WebAssembly.SuspendError("message") : any +>WebAssembly.SuspendError : any +>WebAssembly : typeof WebAssembly +>SuspendError : any +>"message" : "message" + +const err2: WebAssembly.SuspendError = WebAssembly.SuspendError(); +>err2 : WebAssembly.SuspendError +>WebAssembly : any +>WebAssembly.SuspendError() : any +>WebAssembly.SuspendError : any +>WebAssembly : typeof WebAssembly +>SuspendError : any + +new WebAssembly.Suspending(42); // error +>new WebAssembly.Suspending(42) : any +>WebAssembly.Suspending : any +>WebAssembly : typeof WebAssembly +>Suspending : any +>42 : 42 + +WebAssembly.promising("not a function"); // error +>WebAssembly.promising("not a function") : any +>WebAssembly.promising : any +>WebAssembly : typeof WebAssembly +>promising : any +>"not a function" : "not a function" + diff --git a/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegrationWebworker.errors.txt b/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegrationWebworker.errors.txt new file mode 100644 index 0000000000000..a986e888148cf --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegrationWebworker.errors.txt @@ -0,0 +1,27 @@ +webAssemblyPromiseIntegrationWebworker.ts(4,35): error TS2339: Property 'Suspending' does not exist on type 'typeof WebAssembly'. +webAssemblyPromiseIntegrationWebworker.ts(7,39): error TS2339: Property 'promising' does not exist on type 'typeof WebAssembly'. +webAssemblyPromiseIntegrationWebworker.ts(11,24): error TS2694: Namespace 'WebAssembly' has no exported member 'SuspendError'. +webAssemblyPromiseIntegrationWebworker.ts(11,55): error TS2339: Property 'SuspendError' does not exist on type 'typeof WebAssembly'. + + +==== webAssemblyPromiseIntegrationWebworker.ts (4 errors) ==== + async function main(bytes: ArrayBuffer) { + const { instance } = await WebAssembly.instantiate(bytes, { + env: { + wait: new WebAssembly.Suspending(() => new Promise(resolve => setTimeout(resolve, 10))), + ~~~~~~~~~~ +!!! error TS2339: Property 'Suspending' does not exist on type 'typeof WebAssembly'. + }, + }); + const run: Function = WebAssembly.promising(instance.exports.run as Function); + ~~~~~~~~~ +!!! error TS2339: Property 'promising' does not exist on type 'typeof WebAssembly'. + await run(); + } + + const err: WebAssembly.SuspendError = new WebAssembly.SuspendError("message"); + ~~~~~~~~~~~~ +!!! error TS2694: Namespace 'WebAssembly' has no exported member 'SuspendError'. + ~~~~~~~~~~~~ +!!! error TS2339: Property 'SuspendError' does not exist on type 'typeof WebAssembly'. + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegrationWebworker.js b/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegrationWebworker.js new file mode 100644 index 0000000000000..7376c79ded00b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegrationWebworker.js @@ -0,0 +1,28 @@ +//// [tests/cases/compiler/webAssemblyPromiseIntegrationWebworker.ts] //// + +//// [webAssemblyPromiseIntegrationWebworker.ts] +async function main(bytes: ArrayBuffer) { + const { instance } = await WebAssembly.instantiate(bytes, { + env: { + wait: new WebAssembly.Suspending(() => new Promise(resolve => setTimeout(resolve, 10))), + }, + }); + const run: Function = WebAssembly.promising(instance.exports.run as Function); + await run(); +} + +const err: WebAssembly.SuspendError = new WebAssembly.SuspendError("message"); + + +//// [webAssemblyPromiseIntegrationWebworker.js] +"use strict"; +async function main(bytes) { + const { instance } = await WebAssembly.instantiate(bytes, { + env: { + wait: new WebAssembly.Suspending(() => new Promise(resolve => setTimeout(resolve, 10))), + }, + }); + const run = WebAssembly.promising(instance.exports.run); + await run(); +} +const err = new WebAssembly.SuspendError("message"); diff --git a/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegrationWebworker.symbols b/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegrationWebworker.symbols new file mode 100644 index 0000000000000..afe0c24aa34c3 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegrationWebworker.symbols @@ -0,0 +1,47 @@ +//// [tests/cases/compiler/webAssemblyPromiseIntegrationWebworker.ts] //// + +=== webAssemblyPromiseIntegrationWebworker.ts === +async function main(bytes: ArrayBuffer) { +>main : Symbol(main, Decl(webAssemblyPromiseIntegrationWebworker.ts, 0, 0)) +>bytes : Symbol(bytes, Decl(webAssemblyPromiseIntegrationWebworker.ts, 0, 20)) +>ArrayBuffer : Symbol(ArrayBuffer, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2024.arraybuffer.d.ts, --, --)) + + const { instance } = await WebAssembly.instantiate(bytes, { +>instance : Symbol(instance, Decl(webAssemblyPromiseIntegrationWebworker.ts, 1, 11)) +>WebAssembly.instantiate : Symbol(WebAssembly.instantiate, Decl(lib.webworker.d.ts, --, --), Decl(lib.webworker.d.ts, --, --)) +>WebAssembly : Symbol(WebAssembly, Decl(lib.webworker.d.ts, --, --)) +>instantiate : Symbol(WebAssembly.instantiate, Decl(lib.webworker.d.ts, --, --), Decl(lib.webworker.d.ts, --, --)) +>bytes : Symbol(bytes, Decl(webAssemblyPromiseIntegrationWebworker.ts, 0, 20)) + + env: { +>env : Symbol(env, Decl(webAssemblyPromiseIntegrationWebworker.ts, 1, 63)) + + wait: new WebAssembly.Suspending(() => new Promise(resolve => setTimeout(resolve, 10))), +>wait : Symbol(wait, Decl(webAssemblyPromiseIntegrationWebworker.ts, 2, 14)) +>WebAssembly : Symbol(WebAssembly, Decl(lib.webworker.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>resolve : Symbol(resolve, Decl(webAssemblyPromiseIntegrationWebworker.ts, 3, 69)) +>setTimeout : Symbol(setTimeout, Decl(lib.webworker.d.ts, --, --)) +>resolve : Symbol(resolve, Decl(webAssemblyPromiseIntegrationWebworker.ts, 3, 69)) + + }, + }); + const run: Function = WebAssembly.promising(instance.exports.run as Function); +>run : Symbol(run, Decl(webAssemblyPromiseIntegrationWebworker.ts, 6, 9)) +>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.decorators.d.ts, --, --)) +>WebAssembly : Symbol(WebAssembly, Decl(lib.webworker.d.ts, --, --)) +>instance.exports : Symbol(WebAssembly.Instance.exports, Decl(lib.webworker.d.ts, --, --)) +>instance : Symbol(instance, Decl(webAssemblyPromiseIntegrationWebworker.ts, 1, 11)) +>exports : Symbol(WebAssembly.Instance.exports, Decl(lib.webworker.d.ts, --, --)) +>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.decorators.d.ts, --, --)) + + await run(); +>run : Symbol(run, Decl(webAssemblyPromiseIntegrationWebworker.ts, 6, 9)) +} + +const err: WebAssembly.SuspendError = new WebAssembly.SuspendError("message"); +>err : Symbol(err, Decl(webAssemblyPromiseIntegrationWebworker.ts, 10, 5)) +>WebAssembly : Symbol(WebAssembly, Decl(lib.webworker.d.ts, --, --)) +>SuspendError : Symbol(WebAssembly.SuspendError) +>WebAssembly : Symbol(WebAssembly, Decl(lib.webworker.d.ts, --, --)) + diff --git a/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegrationWebworker.types b/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegrationWebworker.types new file mode 100644 index 0000000000000..40cab68c2e38a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegrationWebworker.types @@ -0,0 +1,67 @@ +//// [tests/cases/compiler/webAssemblyPromiseIntegrationWebworker.ts] //// + +=== webAssemblyPromiseIntegrationWebworker.ts === +async function main(bytes: ArrayBuffer) { +>main : (bytes: ArrayBuffer) => Promise +>bytes : ArrayBuffer + + const { instance } = await WebAssembly.instantiate(bytes, { +>instance : WebAssembly.Instance +>await WebAssembly.instantiate(bytes, { env: { wait: new WebAssembly.Suspending(() => new Promise(resolve => setTimeout(resolve, 10))), }, }) : WebAssembly.WebAssemblyInstantiatedSource +>WebAssembly.instantiate(bytes, { env: { wait: new WebAssembly.Suspending(() => new Promise(resolve => setTimeout(resolve, 10))), }, }) : Promise +>WebAssembly.instantiate : { (bytes: AllowSharedBufferSource, importObject?: WebAssembly.Imports, options?: WebAssembly.WebAssemblyCompileOptions): Promise; (moduleObject: WebAssembly.Module, importObject?: WebAssembly.Imports): Promise; } +>WebAssembly : typeof WebAssembly +>instantiate : { (bytes: AllowSharedBufferSource, importObject?: WebAssembly.Imports, options?: WebAssembly.WebAssemblyCompileOptions): Promise; (moduleObject: WebAssembly.Module, importObject?: WebAssembly.Imports): Promise; } +>bytes : ArrayBuffer +>{ env: { wait: new WebAssembly.Suspending(() => new Promise(resolve => setTimeout(resolve, 10))), }, } : { env: { wait: any; }; } + + env: { +>env : { wait: any; } +>{ wait: new WebAssembly.Suspending(() => new Promise(resolve => setTimeout(resolve, 10))), } : { wait: any; } + + wait: new WebAssembly.Suspending(() => new Promise(resolve => setTimeout(resolve, 10))), +>wait : any +>new WebAssembly.Suspending(() => new Promise(resolve => setTimeout(resolve, 10))) : any +>WebAssembly.Suspending : any +>WebAssembly : typeof WebAssembly +>Suspending : any +>() => new Promise(resolve => setTimeout(resolve, 10)) : () => Promise +>new Promise(resolve => setTimeout(resolve, 10)) : Promise +>Promise : PromiseConstructor +>resolve => setTimeout(resolve, 10) : (resolve: (value: void | PromiseLike) => void) => number +>resolve : (value: void | PromiseLike) => void +>setTimeout(resolve, 10) : number +>setTimeout : (handler: TimerHandler, timeout?: number, ...arguments: any[]) => number +>resolve : (value: void | PromiseLike) => void +>10 : 10 + + }, + }); + const run: Function = WebAssembly.promising(instance.exports.run as Function); +>run : Function +>WebAssembly.promising(instance.exports.run as Function) : any +>WebAssembly.promising : any +>WebAssembly : typeof WebAssembly +>promising : any +>instance.exports.run as Function : Function +>instance.exports.run : WebAssembly.ExportValue +>instance.exports : WebAssembly.Exports +>instance : WebAssembly.Instance +>exports : WebAssembly.Exports +>run : WebAssembly.ExportValue + + await run(); +>await run() : any +>run() : any +>run : Function +} + +const err: WebAssembly.SuspendError = new WebAssembly.SuspendError("message"); +>err : WebAssembly.SuspendError +>WebAssembly : any +>new WebAssembly.SuspendError("message") : any +>WebAssembly.SuspendError : any +>WebAssembly : typeof WebAssembly +>SuspendError : any +>"message" : "message" + diff --git a/tsc/testdata/tests/cases/compiler/webAssemblyPromiseIntegration.ts b/tsc/testdata/tests/cases/compiler/webAssemblyPromiseIntegration.ts new file mode 100644 index 0000000000000..2de47f7a94242 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/webAssemblyPromiseIntegration.ts @@ -0,0 +1,38 @@ +// @target: esnext +// @lib: esnext,dom +// @strict: true + +function someAsyncFunction() { + return fetch("https://example.com").then(result => result.status); +} + +const suspending: WebAssembly.Suspending = new WebAssembly.Suspending(someAsyncFunction); + +const importObj = { + someAsyncFunction: suspending, +}; + +async function main() { + const { instance } = await WebAssembly.instantiateStreaming(fetch("module.wasm"), { importObj }); + const run: Function = WebAssembly.promising(instance.exports.run as Function); + await run(); +} + +const imports: WebAssembly.Imports = { + env: { + sync: () => 0, + async: new WebAssembly.Suspending(async () => 0), + }, +}; + +function handle(e: unknown) { + if (e instanceof WebAssembly.SuspendError) { + const err: Error = e; + } +} + +const err1: WebAssembly.SuspendError = new WebAssembly.SuspendError("message"); +const err2: WebAssembly.SuspendError = WebAssembly.SuspendError(); + +new WebAssembly.Suspending(42); // error +WebAssembly.promising("not a function"); // error diff --git a/tsc/testdata/tests/cases/compiler/webAssemblyPromiseIntegrationWebworker.ts b/tsc/testdata/tests/cases/compiler/webAssemblyPromiseIntegrationWebworker.ts new file mode 100644 index 0000000000000..dc5a82627a1d4 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/webAssemblyPromiseIntegrationWebworker.ts @@ -0,0 +1,15 @@ +// @target: esnext +// @lib: esnext,webworker +// @strict: true + +async function main(bytes: ArrayBuffer) { + const { instance } = await WebAssembly.instantiate(bytes, { + env: { + wait: new WebAssembly.Suspending(() => new Promise(resolve => setTimeout(resolve, 10))), + }, + }); + const run: Function = WebAssembly.promising(instance.exports.run as Function); + await run(); +} + +const err: WebAssembly.SuspendError = new WebAssembly.SuspendError("message"); From 7f463da0092c13c9a366807e5350ff9b4b291c25 Mon Sep 17 00:00:00 2001 From: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> Date: Fri, 4 Dec 2026 18:57:42 +0000 Subject: [PATCH 3/3] Add WebAssembly.Suspending, WebAssembly.promising, and WebAssembly.SuspendError to DOM and WebWorker libs Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- tsc/internal/bundled/libs/lib.dom.d.ts | 27 ++++++++- tsc/internal/bundled/libs/lib.webworker.d.ts | 27 ++++++++- .../webAssemblyPromiseIntegration.errors.txt | 44 +++------------ .../webAssemblyPromiseIntegration.symbols | 22 +++++++- .../webAssemblyPromiseIntegration.types | 56 +++++++++---------- ...mblyPromiseIntegrationWebworker.errors.txt | 27 --------- ...ssemblyPromiseIntegrationWebworker.symbols | 8 ++- ...bAssemblyPromiseIntegrationWebworker.types | 26 ++++----- 8 files changed, 126 insertions(+), 111 deletions(-) delete mode 100644 tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegrationWebworker.errors.txt diff --git a/tsc/internal/bundled/libs/lib.dom.d.ts b/tsc/internal/bundled/libs/lib.dom.d.ts index 7f436fb0854d0..2b75c7e7fe5b6 100644 --- a/tsc/internal/bundled/libs/lib.dom.d.ts +++ b/tsc/internal/bundled/libs/lib.dom.d.ts @@ -43547,6 +43547,29 @@ declare namespace WebAssembly { (message?: string): RuntimeError; }; + /** The **`WebAssembly.SuspendError`** object indicates an error during WebAssembly function suspension. */ + interface SuspendError extends Error { + } + + var SuspendError: { + prototype: SuspendError; + new(message?: string): SuspendError; + (message?: string): SuspendError; + }; + + /** + * The **`WebAssembly.Suspending`** object represents a suspending function — an asynchronous (Promise-based) JavaScript function that, when imported into a Wasm module and called from inside, will result in execution being suspended until the promise resolves. + * + * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Suspending) + */ + interface Suspending { + } + + var Suspending: { + prototype: Suspending; + new(jsFun: Function): Suspending; + }; + /** * The **`WebAssembly.Table`** object is a JavaScript wrapper object — an array-like structure representing a WebAssembly table, which stores homogeneous references. A table created by JavaScript or in WebAssembly code will be accessible and mutable from both JavaScript and WebAssembly. * @@ -43661,7 +43684,7 @@ declare namespace WebAssembly { type AddressValue = number; type ExportValue = Function | Global | Memory | Table; type Exports = Record; - type ImportValue = ExportValue | number; + type ImportValue = ExportValue | Suspending | number; type Imports = Record; type ModuleImports = Record; type ValueType = keyof ValueTypeMap; @@ -43675,6 +43698,8 @@ declare namespace WebAssembly { function instantiate(moduleObject: Module, importObject?: Imports): Promise; /** [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/instantiateStreaming_static) */ function instantiateStreaming(source: Response | PromiseLike, importObject?: Imports, options?: WebAssemblyCompileOptions): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/promising_static) */ + function promising(wasmFunc: Function): Function; /** [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/validate_static) */ function validate(bytes: AllowSharedBufferSource, options?: WebAssemblyCompileOptions): boolean; } diff --git a/tsc/internal/bundled/libs/lib.webworker.d.ts b/tsc/internal/bundled/libs/lib.webworker.d.ts index 25f2e29b3261e..fad05b90bcc8e 100644 --- a/tsc/internal/bundled/libs/lib.webworker.d.ts +++ b/tsc/internal/bundled/libs/lib.webworker.d.ts @@ -14896,6 +14896,29 @@ declare namespace WebAssembly { (message?: string): RuntimeError; }; + /** The **`WebAssembly.SuspendError`** object indicates an error during WebAssembly function suspension. */ + interface SuspendError extends Error { + } + + var SuspendError: { + prototype: SuspendError; + new(message?: string): SuspendError; + (message?: string): SuspendError; + }; + + /** + * The **`WebAssembly.Suspending`** object represents a suspending function — an asynchronous (Promise-based) JavaScript function that, when imported into a Wasm module and called from inside, will result in execution being suspended until the promise resolves. + * + * [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/Suspending) + */ + interface Suspending { + } + + var Suspending: { + prototype: Suspending; + new(jsFun: Function): Suspending; + }; + /** * The **`WebAssembly.Table`** object is a JavaScript wrapper object — an array-like structure representing a WebAssembly table, which stores homogeneous references. A table created by JavaScript or in WebAssembly code will be accessible and mutable from both JavaScript and WebAssembly. * @@ -15010,7 +15033,7 @@ declare namespace WebAssembly { type AddressValue = number; type ExportValue = Function | Global | Memory | Table; type Exports = Record; - type ImportValue = ExportValue | number; + type ImportValue = ExportValue | Suspending | number; type Imports = Record; type ModuleImports = Record; type ValueType = keyof ValueTypeMap; @@ -15024,6 +15047,8 @@ declare namespace WebAssembly { function instantiate(moduleObject: Module, importObject?: Imports): Promise; /** [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/instantiateStreaming_static) */ function instantiateStreaming(source: Response | PromiseLike, importObject?: Imports, options?: WebAssemblyCompileOptions): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/promising_static) */ + function promising(wasmFunc: Function): Function; /** [MDN Reference](https://developer.mozilla.org/docs/WebAssembly/Reference/JavaScript_interface/validate_static) */ function validate(bytes: AllowSharedBufferSource, options?: WebAssemblyCompileOptions): boolean; } diff --git a/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegration.errors.txt b/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegration.errors.txt index 22ab54eeeb788..f909020e2139e 100644 --- a/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegration.errors.txt +++ b/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegration.errors.txt @@ -1,27 +1,13 @@ -webAssemblyPromiseIntegration.ts(5,31): error TS2694: Namespace 'WebAssembly' has no exported member 'Suspending'. -webAssemblyPromiseIntegration.ts(5,60): error TS2339: Property 'Suspending' does not exist on type 'typeof WebAssembly'. -webAssemblyPromiseIntegration.ts(13,39): error TS2339: Property 'promising' does not exist on type 'typeof WebAssembly'. -webAssemblyPromiseIntegration.ts(20,32): error TS2339: Property 'Suspending' does not exist on type 'typeof WebAssembly'. -webAssemblyPromiseIntegration.ts(25,34): error TS2339: Property 'SuspendError' does not exist on type 'typeof WebAssembly'. -webAssemblyPromiseIntegration.ts(26,15): error TS2322: Type 'unknown' is not assignable to type 'Error'. -webAssemblyPromiseIntegration.ts(30,25): error TS2694: Namespace 'WebAssembly' has no exported member 'SuspendError'. -webAssemblyPromiseIntegration.ts(30,56): error TS2339: Property 'SuspendError' does not exist on type 'typeof WebAssembly'. -webAssemblyPromiseIntegration.ts(31,25): error TS2694: Namespace 'WebAssembly' has no exported member 'SuspendError'. -webAssemblyPromiseIntegration.ts(31,52): error TS2339: Property 'SuspendError' does not exist on type 'typeof WebAssembly'. -webAssemblyPromiseIntegration.ts(33,17): error TS2339: Property 'Suspending' does not exist on type 'typeof WebAssembly'. -webAssemblyPromiseIntegration.ts(34,13): error TS2339: Property 'promising' does not exist on type 'typeof WebAssembly'. +webAssemblyPromiseIntegration.ts(33,28): error TS2345: Argument of type 'number' is not assignable to parameter of type 'Function'. +webAssemblyPromiseIntegration.ts(34,23): error TS2345: Argument of type 'string' is not assignable to parameter of type 'Function'. -==== webAssemblyPromiseIntegration.ts (12 errors) ==== +==== webAssemblyPromiseIntegration.ts (2 errors) ==== function someAsyncFunction() { return fetch("https://example.com").then(result => result.status); } const suspending: WebAssembly.Suspending = new WebAssembly.Suspending(someAsyncFunction); - ~~~~~~~~~~ -!!! error TS2694: Namespace 'WebAssembly' has no exported member 'Suspending'. - ~~~~~~~~~~ -!!! error TS2339: Property 'Suspending' does not exist on type 'typeof WebAssembly'. const importObj = { someAsyncFunction: suspending, @@ -30,8 +16,6 @@ webAssemblyPromiseIntegration.ts(34,13): error TS2339: Property 'promising' does async function main() { const { instance } = await WebAssembly.instantiateStreaming(fetch("module.wasm"), { importObj }); const run: Function = WebAssembly.promising(instance.exports.run as Function); - ~~~~~~~~~ -!!! error TS2339: Property 'promising' does not exist on type 'typeof WebAssembly'. await run(); } @@ -39,36 +23,22 @@ webAssemblyPromiseIntegration.ts(34,13): error TS2339: Property 'promising' does env: { sync: () => 0, async: new WebAssembly.Suspending(async () => 0), - ~~~~~~~~~~ -!!! error TS2339: Property 'Suspending' does not exist on type 'typeof WebAssembly'. }, }; function handle(e: unknown) { if (e instanceof WebAssembly.SuspendError) { - ~~~~~~~~~~~~ -!!! error TS2339: Property 'SuspendError' does not exist on type 'typeof WebAssembly'. const err: Error = e; - ~~~ -!!! error TS2322: Type 'unknown' is not assignable to type 'Error'. } } const err1: WebAssembly.SuspendError = new WebAssembly.SuspendError("message"); - ~~~~~~~~~~~~ -!!! error TS2694: Namespace 'WebAssembly' has no exported member 'SuspendError'. - ~~~~~~~~~~~~ -!!! error TS2339: Property 'SuspendError' does not exist on type 'typeof WebAssembly'. const err2: WebAssembly.SuspendError = WebAssembly.SuspendError(); - ~~~~~~~~~~~~ -!!! error TS2694: Namespace 'WebAssembly' has no exported member 'SuspendError'. - ~~~~~~~~~~~~ -!!! error TS2339: Property 'SuspendError' does not exist on type 'typeof WebAssembly'. new WebAssembly.Suspending(42); // error - ~~~~~~~~~~ -!!! error TS2339: Property 'Suspending' does not exist on type 'typeof WebAssembly'. + ~~ +!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'Function'. WebAssembly.promising("not a function"); // error - ~~~~~~~~~ -!!! error TS2339: Property 'promising' does not exist on type 'typeof WebAssembly'. + ~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'Function'. \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegration.symbols b/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegration.symbols index c63938ca02421..00b115085a137 100644 --- a/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegration.symbols +++ b/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegration.symbols @@ -17,8 +17,10 @@ function someAsyncFunction() { const suspending: WebAssembly.Suspending = new WebAssembly.Suspending(someAsyncFunction); >suspending : Symbol(suspending, Decl(webAssemblyPromiseIntegration.ts, 4, 5)) >WebAssembly : Symbol(WebAssembly, Decl(lib.dom.d.ts, --, --)) ->Suspending : Symbol(WebAssembly.Suspending) +>Suspending : Symbol(WebAssembly.Suspending, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>WebAssembly.Suspending : Symbol(WebAssembly.Suspending, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) >WebAssembly : Symbol(WebAssembly, Decl(lib.dom.d.ts, --, --)) +>Suspending : Symbol(WebAssembly.Suspending, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) >someAsyncFunction : Symbol(someAsyncFunction, Decl(webAssemblyPromiseIntegration.ts, 0, 0)) const importObj = { @@ -44,7 +46,9 @@ async function main() { const run: Function = WebAssembly.promising(instance.exports.run as Function); >run : Symbol(run, Decl(webAssemblyPromiseIntegration.ts, 12, 9)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.decorators.d.ts, --, --)) +>WebAssembly.promising : Symbol(WebAssembly.promising, Decl(lib.dom.d.ts, --, --)) >WebAssembly : Symbol(WebAssembly, Decl(lib.dom.d.ts, --, --)) +>promising : Symbol(WebAssembly.promising, Decl(lib.dom.d.ts, --, --)) >instance.exports : Symbol(WebAssembly.Instance.exports, Decl(lib.dom.d.ts, --, --)) >instance : Symbol(instance, Decl(webAssemblyPromiseIntegration.ts, 11, 11)) >exports : Symbol(WebAssembly.Instance.exports, Decl(lib.dom.d.ts, --, --)) @@ -67,7 +71,9 @@ const imports: WebAssembly.Imports = { async: new WebAssembly.Suspending(async () => 0), >async : Symbol(async, Decl(webAssemblyPromiseIntegration.ts, 18, 22)) +>WebAssembly.Suspending : Symbol(WebAssembly.Suspending, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) >WebAssembly : Symbol(WebAssembly, Decl(lib.dom.d.ts, --, --)) +>Suspending : Symbol(WebAssembly.Suspending, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) }, }; @@ -78,7 +84,9 @@ function handle(e: unknown) { if (e instanceof WebAssembly.SuspendError) { >e : Symbol(e, Decl(webAssemblyPromiseIntegration.ts, 23, 16)) +>WebAssembly.SuspendError : Symbol(WebAssembly.SuspendError, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) >WebAssembly : Symbol(WebAssembly, Decl(lib.dom.d.ts, --, --)) +>SuspendError : Symbol(WebAssembly.SuspendError, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) const err: Error = e; >err : Symbol(err, Decl(webAssemblyPromiseIntegration.ts, 25, 13)) @@ -90,18 +98,26 @@ function handle(e: unknown) { const err1: WebAssembly.SuspendError = new WebAssembly.SuspendError("message"); >err1 : Symbol(err1, Decl(webAssemblyPromiseIntegration.ts, 29, 5)) >WebAssembly : Symbol(WebAssembly, Decl(lib.dom.d.ts, --, --)) ->SuspendError : Symbol(WebAssembly.SuspendError) +>SuspendError : Symbol(WebAssembly.SuspendError, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>WebAssembly.SuspendError : Symbol(WebAssembly.SuspendError, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) >WebAssembly : Symbol(WebAssembly, Decl(lib.dom.d.ts, --, --)) +>SuspendError : Symbol(WebAssembly.SuspendError, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) const err2: WebAssembly.SuspendError = WebAssembly.SuspendError(); >err2 : Symbol(err2, Decl(webAssemblyPromiseIntegration.ts, 30, 5)) >WebAssembly : Symbol(WebAssembly, Decl(lib.dom.d.ts, --, --)) ->SuspendError : Symbol(WebAssembly.SuspendError) +>SuspendError : Symbol(WebAssembly.SuspendError, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>WebAssembly.SuspendError : Symbol(WebAssembly.SuspendError, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) >WebAssembly : Symbol(WebAssembly, Decl(lib.dom.d.ts, --, --)) +>SuspendError : Symbol(WebAssembly.SuspendError, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) new WebAssembly.Suspending(42); // error +>WebAssembly.Suspending : Symbol(WebAssembly.Suspending, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) >WebAssembly : Symbol(WebAssembly, Decl(lib.dom.d.ts, --, --)) +>Suspending : Symbol(WebAssembly.Suspending, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) WebAssembly.promising("not a function"); // error +>WebAssembly.promising : Symbol(WebAssembly.promising, Decl(lib.dom.d.ts, --, --)) >WebAssembly : Symbol(WebAssembly, Decl(lib.dom.d.ts, --, --)) +>promising : Symbol(WebAssembly.promising, Decl(lib.dom.d.ts, --, --)) diff --git a/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegration.types b/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegration.types index 3a13d69b16d1e..b5a26f76f6542 100644 --- a/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegration.types +++ b/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegration.types @@ -21,10 +21,10 @@ function someAsyncFunction() { const suspending: WebAssembly.Suspending = new WebAssembly.Suspending(someAsyncFunction); >suspending : WebAssembly.Suspending >WebAssembly : any ->new WebAssembly.Suspending(someAsyncFunction) : any ->WebAssembly.Suspending : any +>new WebAssembly.Suspending(someAsyncFunction) : WebAssembly.Suspending +>WebAssembly.Suspending : { new (jsFun: Function): WebAssembly.Suspending; prototype: WebAssembly.Suspending; } >WebAssembly : typeof WebAssembly ->Suspending : any +>Suspending : { new (jsFun: Function): WebAssembly.Suspending; prototype: WebAssembly.Suspending; } >someAsyncFunction : () => Promise const importObj = { @@ -55,10 +55,10 @@ async function main() { const run: Function = WebAssembly.promising(instance.exports.run as Function); >run : Function ->WebAssembly.promising(instance.exports.run as Function) : any ->WebAssembly.promising : any +>WebAssembly.promising(instance.exports.run as Function) : Function +>WebAssembly.promising : (wasmFunc: Function) => Function >WebAssembly : typeof WebAssembly ->promising : any +>promising : (wasmFunc: Function) => Function >instance.exports.run as Function : Function >instance.exports.run : WebAssembly.ExportValue >instance.exports : WebAssembly.Exports @@ -75,11 +75,11 @@ async function main() { const imports: WebAssembly.Imports = { >imports : WebAssembly.Imports >WebAssembly : any ->{ env: { sync: () => 0, async: new WebAssembly.Suspending(async () => 0), },} : { env: { sync: () => number; async: any; }; } +>{ env: { sync: () => 0, async: new WebAssembly.Suspending(async () => 0), },} : { env: { sync: () => number; async: WebAssembly.Suspending; }; } env: { ->env : { sync: () => number; async: any; } ->{ sync: () => 0, async: new WebAssembly.Suspending(async () => 0), } : { sync: () => number; async: any; } +>env : { sync: () => number; async: WebAssembly.Suspending; } +>{ sync: () => 0, async: new WebAssembly.Suspending(async () => 0), } : { sync: () => number; async: WebAssembly.Suspending; } sync: () => 0, >sync : () => number @@ -87,11 +87,11 @@ const imports: WebAssembly.Imports = { >0 : 0 async: new WebAssembly.Suspending(async () => 0), ->async : any ->new WebAssembly.Suspending(async () => 0) : any ->WebAssembly.Suspending : any +>async : WebAssembly.Suspending +>new WebAssembly.Suspending(async () => 0) : WebAssembly.Suspending +>WebAssembly.Suspending : { new (jsFun: Function): WebAssembly.Suspending; prototype: WebAssembly.Suspending; } >WebAssembly : typeof WebAssembly ->Suspending : any +>Suspending : { new (jsFun: Function): WebAssembly.Suspending; prototype: WebAssembly.Suspending; } >async () => 0 : () => Promise >0 : 0 @@ -105,44 +105,44 @@ function handle(e: unknown) { if (e instanceof WebAssembly.SuspendError) { >e instanceof WebAssembly.SuspendError : boolean >e : unknown ->WebAssembly.SuspendError : any +>WebAssembly.SuspendError : { (message?: string): WebAssembly.SuspendError; new (message?: string): WebAssembly.SuspendError; prototype: WebAssembly.SuspendError; } >WebAssembly : typeof WebAssembly ->SuspendError : any +>SuspendError : { (message?: string): WebAssembly.SuspendError; new (message?: string): WebAssembly.SuspendError; prototype: WebAssembly.SuspendError; } const err: Error = e; >err : Error ->e : unknown +>e : WebAssembly.SuspendError } } const err1: WebAssembly.SuspendError = new WebAssembly.SuspendError("message"); >err1 : WebAssembly.SuspendError >WebAssembly : any ->new WebAssembly.SuspendError("message") : any ->WebAssembly.SuspendError : any +>new WebAssembly.SuspendError("message") : WebAssembly.SuspendError +>WebAssembly.SuspendError : { (message?: string): WebAssembly.SuspendError; new (message?: string): WebAssembly.SuspendError; prototype: WebAssembly.SuspendError; } >WebAssembly : typeof WebAssembly ->SuspendError : any +>SuspendError : { (message?: string): WebAssembly.SuspendError; new (message?: string): WebAssembly.SuspendError; prototype: WebAssembly.SuspendError; } >"message" : "message" const err2: WebAssembly.SuspendError = WebAssembly.SuspendError(); >err2 : WebAssembly.SuspendError >WebAssembly : any ->WebAssembly.SuspendError() : any ->WebAssembly.SuspendError : any +>WebAssembly.SuspendError() : WebAssembly.SuspendError +>WebAssembly.SuspendError : { (message?: string): WebAssembly.SuspendError; new (message?: string): WebAssembly.SuspendError; prototype: WebAssembly.SuspendError; } >WebAssembly : typeof WebAssembly ->SuspendError : any +>SuspendError : { (message?: string): WebAssembly.SuspendError; new (message?: string): WebAssembly.SuspendError; prototype: WebAssembly.SuspendError; } new WebAssembly.Suspending(42); // error ->new WebAssembly.Suspending(42) : any ->WebAssembly.Suspending : any +>new WebAssembly.Suspending(42) : WebAssembly.Suspending +>WebAssembly.Suspending : { new (jsFun: Function): WebAssembly.Suspending; prototype: WebAssembly.Suspending; } >WebAssembly : typeof WebAssembly ->Suspending : any +>Suspending : { new (jsFun: Function): WebAssembly.Suspending; prototype: WebAssembly.Suspending; } >42 : 42 WebAssembly.promising("not a function"); // error ->WebAssembly.promising("not a function") : any ->WebAssembly.promising : any +>WebAssembly.promising("not a function") : Function +>WebAssembly.promising : (wasmFunc: Function) => Function >WebAssembly : typeof WebAssembly ->promising : any +>promising : (wasmFunc: Function) => Function >"not a function" : "not a function" diff --git a/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegrationWebworker.errors.txt b/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegrationWebworker.errors.txt deleted file mode 100644 index a986e888148cf..0000000000000 --- a/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegrationWebworker.errors.txt +++ /dev/null @@ -1,27 +0,0 @@ -webAssemblyPromiseIntegrationWebworker.ts(4,35): error TS2339: Property 'Suspending' does not exist on type 'typeof WebAssembly'. -webAssemblyPromiseIntegrationWebworker.ts(7,39): error TS2339: Property 'promising' does not exist on type 'typeof WebAssembly'. -webAssemblyPromiseIntegrationWebworker.ts(11,24): error TS2694: Namespace 'WebAssembly' has no exported member 'SuspendError'. -webAssemblyPromiseIntegrationWebworker.ts(11,55): error TS2339: Property 'SuspendError' does not exist on type 'typeof WebAssembly'. - - -==== webAssemblyPromiseIntegrationWebworker.ts (4 errors) ==== - async function main(bytes: ArrayBuffer) { - const { instance } = await WebAssembly.instantiate(bytes, { - env: { - wait: new WebAssembly.Suspending(() => new Promise(resolve => setTimeout(resolve, 10))), - ~~~~~~~~~~ -!!! error TS2339: Property 'Suspending' does not exist on type 'typeof WebAssembly'. - }, - }); - const run: Function = WebAssembly.promising(instance.exports.run as Function); - ~~~~~~~~~ -!!! error TS2339: Property 'promising' does not exist on type 'typeof WebAssembly'. - await run(); - } - - const err: WebAssembly.SuspendError = new WebAssembly.SuspendError("message"); - ~~~~~~~~~~~~ -!!! error TS2694: Namespace 'WebAssembly' has no exported member 'SuspendError'. - ~~~~~~~~~~~~ -!!! error TS2339: Property 'SuspendError' does not exist on type 'typeof WebAssembly'. - \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegrationWebworker.symbols b/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegrationWebworker.symbols index afe0c24aa34c3..98429b185e002 100644 --- a/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegrationWebworker.symbols +++ b/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegrationWebworker.symbols @@ -18,7 +18,9 @@ async function main(bytes: ArrayBuffer) { wait: new WebAssembly.Suspending(() => new Promise(resolve => setTimeout(resolve, 10))), >wait : Symbol(wait, Decl(webAssemblyPromiseIntegrationWebworker.ts, 2, 14)) +>WebAssembly.Suspending : Symbol(WebAssembly.Suspending, Decl(lib.webworker.d.ts, --, --), Decl(lib.webworker.d.ts, --, --)) >WebAssembly : Symbol(WebAssembly, Decl(lib.webworker.d.ts, --, --)) +>Suspending : Symbol(WebAssembly.Suspending, Decl(lib.webworker.d.ts, --, --), Decl(lib.webworker.d.ts, --, --)) >Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) >resolve : Symbol(resolve, Decl(webAssemblyPromiseIntegrationWebworker.ts, 3, 69)) >setTimeout : Symbol(setTimeout, Decl(lib.webworker.d.ts, --, --)) @@ -29,7 +31,9 @@ async function main(bytes: ArrayBuffer) { const run: Function = WebAssembly.promising(instance.exports.run as Function); >run : Symbol(run, Decl(webAssemblyPromiseIntegrationWebworker.ts, 6, 9)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.decorators.d.ts, --, --)) +>WebAssembly.promising : Symbol(WebAssembly.promising, Decl(lib.webworker.d.ts, --, --)) >WebAssembly : Symbol(WebAssembly, Decl(lib.webworker.d.ts, --, --)) +>promising : Symbol(WebAssembly.promising, Decl(lib.webworker.d.ts, --, --)) >instance.exports : Symbol(WebAssembly.Instance.exports, Decl(lib.webworker.d.ts, --, --)) >instance : Symbol(instance, Decl(webAssemblyPromiseIntegrationWebworker.ts, 1, 11)) >exports : Symbol(WebAssembly.Instance.exports, Decl(lib.webworker.d.ts, --, --)) @@ -42,6 +46,8 @@ async function main(bytes: ArrayBuffer) { const err: WebAssembly.SuspendError = new WebAssembly.SuspendError("message"); >err : Symbol(err, Decl(webAssemblyPromiseIntegrationWebworker.ts, 10, 5)) >WebAssembly : Symbol(WebAssembly, Decl(lib.webworker.d.ts, --, --)) ->SuspendError : Symbol(WebAssembly.SuspendError) +>SuspendError : Symbol(WebAssembly.SuspendError, Decl(lib.webworker.d.ts, --, --), Decl(lib.webworker.d.ts, --, --)) +>WebAssembly.SuspendError : Symbol(WebAssembly.SuspendError, Decl(lib.webworker.d.ts, --, --), Decl(lib.webworker.d.ts, --, --)) >WebAssembly : Symbol(WebAssembly, Decl(lib.webworker.d.ts, --, --)) +>SuspendError : Symbol(WebAssembly.SuspendError, Decl(lib.webworker.d.ts, --, --), Decl(lib.webworker.d.ts, --, --)) diff --git a/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegrationWebworker.types b/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegrationWebworker.types index 40cab68c2e38a..e238a8e9fc0ba 100644 --- a/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegrationWebworker.types +++ b/tsc/testdata/baselines/reference/compiler/webAssemblyPromiseIntegrationWebworker.types @@ -13,18 +13,18 @@ async function main(bytes: ArrayBuffer) { >WebAssembly : typeof WebAssembly >instantiate : { (bytes: AllowSharedBufferSource, importObject?: WebAssembly.Imports, options?: WebAssembly.WebAssemblyCompileOptions): Promise; (moduleObject: WebAssembly.Module, importObject?: WebAssembly.Imports): Promise; } >bytes : ArrayBuffer ->{ env: { wait: new WebAssembly.Suspending(() => new Promise(resolve => setTimeout(resolve, 10))), }, } : { env: { wait: any; }; } +>{ env: { wait: new WebAssembly.Suspending(() => new Promise(resolve => setTimeout(resolve, 10))), }, } : { env: { wait: WebAssembly.Suspending; }; } env: { ->env : { wait: any; } ->{ wait: new WebAssembly.Suspending(() => new Promise(resolve => setTimeout(resolve, 10))), } : { wait: any; } +>env : { wait: WebAssembly.Suspending; } +>{ wait: new WebAssembly.Suspending(() => new Promise(resolve => setTimeout(resolve, 10))), } : { wait: WebAssembly.Suspending; } wait: new WebAssembly.Suspending(() => new Promise(resolve => setTimeout(resolve, 10))), ->wait : any ->new WebAssembly.Suspending(() => new Promise(resolve => setTimeout(resolve, 10))) : any ->WebAssembly.Suspending : any +>wait : WebAssembly.Suspending +>new WebAssembly.Suspending(() => new Promise(resolve => setTimeout(resolve, 10))) : WebAssembly.Suspending +>WebAssembly.Suspending : { new (jsFun: Function): WebAssembly.Suspending; prototype: WebAssembly.Suspending; } >WebAssembly : typeof WebAssembly ->Suspending : any +>Suspending : { new (jsFun: Function): WebAssembly.Suspending; prototype: WebAssembly.Suspending; } >() => new Promise(resolve => setTimeout(resolve, 10)) : () => Promise >new Promise(resolve => setTimeout(resolve, 10)) : Promise >Promise : PromiseConstructor @@ -39,10 +39,10 @@ async function main(bytes: ArrayBuffer) { }); const run: Function = WebAssembly.promising(instance.exports.run as Function); >run : Function ->WebAssembly.promising(instance.exports.run as Function) : any ->WebAssembly.promising : any +>WebAssembly.promising(instance.exports.run as Function) : Function +>WebAssembly.promising : (wasmFunc: Function) => Function >WebAssembly : typeof WebAssembly ->promising : any +>promising : (wasmFunc: Function) => Function >instance.exports.run as Function : Function >instance.exports.run : WebAssembly.ExportValue >instance.exports : WebAssembly.Exports @@ -59,9 +59,9 @@ async function main(bytes: ArrayBuffer) { const err: WebAssembly.SuspendError = new WebAssembly.SuspendError("message"); >err : WebAssembly.SuspendError >WebAssembly : any ->new WebAssembly.SuspendError("message") : any ->WebAssembly.SuspendError : any +>new WebAssembly.SuspendError("message") : WebAssembly.SuspendError +>WebAssembly.SuspendError : { (message?: string): WebAssembly.SuspendError; new (message?: string): WebAssembly.SuspendError; prototype: WebAssembly.SuspendError; } >WebAssembly : typeof WebAssembly ->SuspendError : any +>SuspendError : { (message?: string): WebAssembly.SuspendError; new (message?: string): WebAssembly.SuspendError; prototype: WebAssembly.SuspendError; } >"message" : "message"