Skip to content

lib.d.ts defines "postMessage" for window, but web worker scripts have a different signature #582

Closed
@xirzec

Description

@xirzec

Webworkers have a global "postMessage(message:any):void" method, but TS uses the "postMessage(message:any, origin:string, ports?:any):void" definition from window.postMessage.

This causes something like

postMessage("Hello");

to be detected as an error, even though it is valid from inside a webworker. Maybe there needs to be a way to indicate to TS (via a comment in the file?) that the current script is intended to be loaded inside a webworker.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions