In the ts project, I introduced dom and WebWorker in compilerOptions -> lib of the tsconfig.json file and then compiled and reported an error.
Below is the tsconfig.json file:
在ts项目中,我在tsconfig.json文件的编译器选项->lib中引入了dom和WebWorker,然后编译并报告了一个错误。以下是tsconfig.json文件:
{
"compilerOptions": {
"lib": ["ES2015", "DOM", "WebWorker"],
"module": "ES2015",
"target": "ES5",
"outDir": "dist",
"sourceMap": false,
"strict": true,
"moduleResolution": "Node",
"esModuleInterop": true,
"preserveConstEnums": true,
"downlevelIteration": true
},
"include": ["src"],
"exclude": ["node_modules"]
}
The error is reported as follows:
错误报告如下:
node_modules/typescript/lib/lib.webworker.d.ts:5725:13 - error TS2403: Subsequent variable declarations must have the same type. Variable 'self' must be of type 'Window & typeof globalThis', but here has type 'WorkerGlobalScope & typeof globalThis'.
5725 declare var self: WorkerGlobalScope & typeof globalThis;
~~~~
node_modules/typescript/lib/lib.dom.d.ts:17364:13
17364 declare var self: Window & typeof globalThis;
~~~~
'self' was also declared here.
I don't know the reason and how to fix it
我不知道原因,也不知道怎么解决
更多回答
优秀答案推荐
我是一名优秀的程序员,十分优秀!