Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
xirzec opened this issue Sep 2, 2014 · 1 comment
Labels
Bug A bug in TypeScript Duplicate An existing issue was already created

Comments

@xirzec
Copy link
Member

xirzec commented Sep 2, 2014

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.

@mhegazy
Copy link
Contributor

mhegazy commented Sep 2, 2014

We have a different library file for webworkers, under lib.webworkers.d.ts. this should have the correct definition. currently there is no way to reference this file except using the full path, which is not ideal. adding a commandline switch to specify which flavor of the library you want is tracked under #494

@mhegazy mhegazy closed this as completed Sep 2, 2014
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants