Skip to content

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

@nickbabcock

Description

@nickbabcock

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

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

Have Tried The Latest Releases

  • This issue applies to the latest release of TypeScript.
  • 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions