Repository navigation
Add WebAssembly.Suspending, WebAssembly.promising, and WebAssembly.SuspendError to DOM and WebWorker libs - #65793
Closed
Ryan Cavanaugh (RyanCavanaugh) wants to merge 3 commits into
Closed
Ryan Cavanaugh (RyanCavanaugh) wants to merge 3 commits into
Ryan Cavanaugh (RyanCavanaugh) wants to merge 3 commits into
Conversation
6 tasks done
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
…spendError to DOM and WebWorker libs Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
WebAssembly.Suspending, WebAssembly.promising, and WebAssembly.SuspendError to DOM and WebWorker libs
Member
Author
|
We need to put this in the DOM generator repo and should brand the interface interface Suspending {
readonly [Symbol.toStringTag]: "WebAssembly.Suspending";
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The libs had no declarations for the WebAssembly JavaScript Promise Integration (JSPI) API.
ImportValuealso rejectedSuspendingobjects, which the spec explicitly allows in import objects. Per MDN compatibility data, JSPI ships unprefixed in Chrome 137, Firefox 153 and Safari 27.Changes (
lib.dom.d.tsandlib.webworker.d.ts, identical edits)Suspending: an empty interface plus avarwithnew(jsFun: Function), following the spec's IDL.SuspendError: an error class shaped likeCompileError,LinkErrorandRuntimeError. It is part of the same spec and shipped in the same browser versions.promising(wasmFunc: Function): Function: a new function on the namespace.ImportValue: changed fromExportValue | numbertoExportValue | Suspending | number.These files are normally generated by TypeScript-DOM-lib-generator, which doesn't have JSPI yet. The edits are by hand but follow the generator's member ordering, doc-comment style and IDL-to-TS type mapping. That should keep the diff small when the generator is updated.
Review notes
ImportValuenow accepts almost any value.Suspendinghas no members, so adding it to the union means values in an import object are only required to be non-nullish. For example,{ env: { s: "str" } }used to be an error and is now accepted. The namespace already does this:instantiate(moduleObject: Module)takes the emptyModuleinterface and so accepts any non-nullish value too. The alternative was to leaveImportValueunchanged and make users cast everySuspendingin an import object.promisingkeeps the spec'sFunctionsignature. It is not typed generically (e.g.(...a: A) => R→(...a: A) => Promise<R>). This matches what the generator will emit, and wasm exports are typed asExportValueanyway, so callers already cast.Tests
webAssemblyPromiseIntegration.ts(dom) andwebAssemblyPromiseIntegrationWebworker.ts(webworker) cover:instantiateStreamingexampleImportsobject containing aSuspendingpromisingSuspendErrorvianew, a plain call andinstanceofnarrowingSuspendingorpromisinggets a non-functionWebAssembly.SuspendingandWebAssembly.promising#65782