欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Cannot find name 'Set'. Do you need to change your target library? Try changing the `lib`compiler

程序员文章站 2022-03-27 20:44:04
...

错误信息
TS2583: Cannot find name ‘Set’. Do you need to change your target library? Try changing the lib compiler option to es2015 or later.

错误截图
Cannot find name 'Set'. Do you need to change your target library? Try changing the `lib`compiler
解决方案:

修改tsconfig.json. 我目前用的版本是"typescript": “^3.7.5”

{
    "compilerOptions": {
        "outDir": "./dist/",
        "sourceMap": true,
        "noImplicitAny": true,
        "module": "commonjs",
        "target": "es6",  //把es5改成es6
        "jsx": "react"
    },
    "include": [
        "./src/**/*"
    ]
}

跟着中文文档https://typescript.bootcss.com/学习React与webpack的时候报的错。可能是之前翻译的时候还是旧版本的typescript。升级后就不能编译了。

相关标签: TypeScript