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

[Web API type definition issue] WebAssembly.Module interface is empty, allowing invalid assignments

Open nickbabcock opened this issue 5 months ago • 1 comments

Summary

The WebAssembly.Module interface is currently emitted as an empty interface, making it structurally compatible with any object in TypeScript

Expected vs. Actual Behavior

const abc: WebAssembly.Module = 0;

I would expect the above to be a compilation error.

But WebAssembly.Module gets emitted as an empty interface allowing all assignments.

interface Module { }

Playground Link

https://www.typescriptlang.org/play/?#code/MYewdgzgLgBAhgI2ALhgdQKYIIIQhgWwQBsBPAOgFkQATAV2IxgF4YAGAbiA

Browser Support

  • [x] This API is supported in at least two major browser engines (not two Chromium-based browsers).

Have Tried The Latest Releases

  • [x] This issue applies to the latest release of TypeScript.
  • [x] This issue applies to the latest release of @types/web.

Additional Context

Do we need to make WebAssembly.Module nominally typed? 🫣

I'm not aware of any other interfaces with only constructors/static methods but no instance members

nickbabcock avatar Sep 29 '25 16:09 nickbabcock

Relates to #2075. I suspect that adding Symbol.toStringTag properties for the TS 6.0 DOM libs is the definitive fix for these cases.

Renegade334 avatar Oct 06 '25 06:10 Renegade334