我更改了我的 tsconfig.json
的配置 Node 项目的文件如下,现在它给出 ESLint: Parsing error: Unknown compiler option 'noUncheckedIndexedAccess'
错误。
tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "lib",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es2018",
"typeRoots": [
"node_modules/@types"
],
"skipLibCheck": true,
"lib": [
"es2017",
"dom"
],
"module": "CommonJS",
"baseUrl": "./",
"noUnusedLocals": true,
"noUnusedParameters": true,
"noUncheckedIndexedAccess": true,
"strictNullChecks": true
}
}
有没有办法解决这个问题?
最佳答案
正如 HTN 在他的评论中指出的那样,noUncheckedIndexedAccess
从 4.1 开始可用。 docs确认这一点。
结果,这是有问题的行:
"noUncheckedIndexedAccess": true,
您的 Typescript 3.8.0 比它尝试使用的功能旧,因此出现错误。您可以使用当前的 Typescript,但删除该行,或者您可以将 Typescript 升级到至少 4.1 版本。这两种方法都可以解决这个问题,但 Typescript 版本升级通常被认为是一种更好的方法,因为它会为您提供新的选择,而不必限制对功能的访问。
关于node.js - ESLint:解析错误:未知编译器选项 'noUncheckedIndexedAccess',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66722368/