Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebAssembly namespace only found in lib.dom.d.ts and not available for NodeJS #47381

Closed
tomaka opened this issue Jan 11, 2022 · 4 comments
Closed
Labels
Duplicate An existing issue was already created

Comments

@tomaka
Copy link

tomaka commented Jan 11, 2022

lib Update Request

Hi 👋

lib.dom.d.ts contains a namespace named WebAssembly in accordance with https://webassembly.github.io/spec/js-api/

However, correct me if I'm wrong, but WebAssembly is not a web-specific technology but a "core" JavaScript API.
NodeJS for example also supports creating/running WebAssembly instances.
And on the MDN, it is classified as a "global object", and not something specific to the web: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects#webassembly

As a consequence, it is not currently possible to use WebAssembly from JavaScript without importing the dom library.
An example of that is that the @types/node/wasi.d.ts file contains dummy return values for its functions:

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/8745cf9f8425bfcabaed69fba1684082a18f3191/types/node/wasi.d.ts#L136

Configuration Check

This issue applies to situations where lib does not contains dom.

Missing / Incorrect Definition

The missing definition is the WebAssembly object/namespace and everything below.

WebAssembly shouldn't be present in the dom library but, if I'm not mistaken, as a language feature.

Sample Code

Any code that uses WebAssembly doesn't work, for example:

await WebAssembly.instantiate(wasmBytecode, {});

Documentation Link

https://www.w3.org/TR/wasm-js-api-1/
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects#webassembly

@IllusionMH
Copy link
Contributor

IllusionMH commented Jan 11, 2022

WASM isn't part of ECMAScript spec and it's just browsers/runtime providing JS API.
Similar to console which is not part of ES spec, but it's may be non-trivial to find runtime that doesn't have it.

UPD. Basically duplicate of microsoft/TypeScript-DOM-lib-generator#826

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Jan 11, 2022
@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

@tomaka
Copy link
Author

tomaka commented Jan 15, 2022

A duplicate of which issue? Is there an issue I can follow to know whether there is a work-around and/or when this is fixed?

@IllusionMH
Copy link
Contributor

UPD. Basically duplicate of microsoft/TypeScript-DOM-lib-generator#826

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants