Skip to content

[Web API type definition issue] MediaSourceHandle results in any #2316

@Banou26

Description

@Banou26

Summary

MediaSourceHandle results in any making Transferable wrong

Expected vs. Actual Behavior

Currently the type generation for MediaSourceHandle results in

/**
 * The **`MediaSourceHandle`** interface of the Media Source Extensions API is a proxy for a MediaSource that can be transferred from a dedicated worker back to the main thread and attached to a media element via its HTMLMediaElement.srcObject property.
 *
 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MediaSourceHandle)
 */
interface MediaSourceHandle {
}

declare var MediaSourceHandle: {
    prototype: MediaSourceHandle;
    new(): MediaSourceHandle;
};

And empty interfaces are known for being equal to any in TS, so this makes Transferable accept any types, which is wrong.

Playground Link

No response

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

Currently using latest typescript 5.9.3

My workaround for now is using this definition.

interface MediaSourceHandle {
  __dummy__: never
}

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