vscode中的eslint報錯:
型別 'this' 只能在使用 '--downlevelIteration' 標志或使用 '--target' 為 'es2015' 或更高版本時迭代。”
我原以為 eslint 會查看我的 tsconfig.json 并看到我已將 TypeScript compilerOptions.target 設定為 es2015。
為了更好地衡量,我還在我的 package.json 中添加了以下內容
"eslintConfig": {
"env": {
"node": true,
"es2015": true
}
}
盡管配置正確,eslint 仍然報錯 ts(2802)。
如何讓 vscode 中的內置 eslint 知道我的目標是 es2015 并且不報告該錯誤?
uj5u.com熱心網友回復:
您不必添加eslintconfig包 json。
確保您在 tsConfig.json -> compilerOptions.target:"target": "es2017"和 package.json => devDependencies 中有:
"eslint": "^8.17.0"
"@angular-eslint/builder": "13.5.0",
"@angular-eslint/eslint-plugin": "13.5.0",
"@angular-eslint/eslint-plugin-template": "13.5.0",
"@angular-eslint/schematics": "13.5.0",
"@angular-eslint/template-parser": "13.5.0",
"@typescript-eslint/eslint-plugin": "5.27.1",
"@typescript-eslint/parser": "5.27.1"
然后確保在專案的根目錄中有 .eslintrc.json 檔案,在 package.json 和 tsconfig.json 檔案旁邊
它對我有用。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/523285.html
