Search code examples
webwebstormdeprecatedworkerpostmessage

WebStorm shows deprecation error in postMessage function of a web worker


When writing something like this in WebStorm:

let webWorker = new Worker('...')
...
webWorker.postMessage(...)

The postMessage is striked out with the following message:

"Deprecated symbol used, consult docs for better alternative"
"Checks for using deprecated JavaScript functions and variables ..."

Is postMessage function of the webWorker is deprecated?


Solution

  • This method is annotated with @deprecated tag in lib.dom.d.ts provided by Microsoft (that, in turn, was auto-generated from the webidl definition of edge); Microsoft has recently fixed the issue in https://github.com/Microsoft/TypeScript/pull/24669, method is no more marked deprecated in https://github.com/Microsoft/TypeScript/blob/master/lib/lib.dom.d.ts.

    Webstorm will bundle Typescript 3.x that includes the fix in upcoming 2018.2.1 update (https://youtrack.jetbrains.com/issue/WEB-34144)