TypeScript-DOM-lib-generator icon indicating copy to clipboard operation
TypeScript-DOM-lib-generator copied to clipboard

Separate WebAssembly types from `lib.dom.d.ts` into their own file

Open ExE-Boss opened this issue 5 years ago • 2 comments

Currently, if you wish to use WebAssembly, you need to include lib.dom.d.ts, even in cases where that’s incorrect (e.g.: NodeJS or Deno).

The solution would be to move non‑web‑specific[^1] WebAssembly types to a new lib.wasm.d.ts file.

[^1]: Web‑specific WebAssembly types are those defined in https://webassembly.github.io/spec/web-api/index.html. Non‑web‑specific WebAssembly types are those defined in https://webassembly.github.io/spec/js-api/index.html.


See also: https://github.com/microsoft/TSJS-lib-generator/issues/211

ExE-Boss avatar Feb 21 '20 10:02 ExE-Boss

+1

Currently I can't define AbortController/AbortSignal/EventTarget/Event for [email protected] because typings include lib.dom.d.ts (with its own implementation of AbortController/AbortSignal, etc.) (https://github.com/DefinitelyTyped/DefinitelyTyped/pull/48981)

Semigradsky avatar Oct 26 '20 14:10 Semigradsky

@Semigradsky That’s unrelated to this.

Your case is happening because you’re defining them using class EventTarget instead of interface EventTarget { ... } and declare var EventTarget: EventTargetConstructor, but that depends on TypeScript language support: https://github.com/microsoft/TypeScript/issues/39054#issuecomment-644299696 and https://github.com/microsoft/TypeScript/issues/39504.

ExE-Boss avatar Oct 26 '20 17:10 ExE-Boss