How do I strongly type a TypeScript web worker file with postMessage?

☆樱花仙子☆ 提交于 2019-12-04 11:20:48

If you check the compiler options you will see that there is a webworker option for --lib. The problem is that you can't compile regular code and code for web worker at the same time. You can put your web worker code in a separate folder with it's own tsconfig.json and copule it separately:

"compilerOptions" : {
    "target": "es2015",
    "lib": [
        "es2015"
        "webworker"
    ]
}

Or you can invoke the compiler explicitly for the webworker code:

tsc .\sample.ts -lib es2015,webworker
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!