当我尝试这样的事情
const d: [number, number] = [1, 2];我得到ts错误:解析错误:无法读取未定义(读取‘map’)属性
是什么导致了这个问题?
。
package.json
"devDependencies": {
"@types/es6-promise": "^3.3.0",
"@types/express": "^4.11.1",
"@types/mongodb": "^3.5.27",
"@types/node": "^12.20.6",
"@types/socket.io": "^1.4.38",
"@typescript-eslint/eslint-plugin": "^2.34.0",
"@typescript-eslint/parser": "^2.34.0",
"cpx": "^1.5.0",
"del-cli": "^1.1.0",
"empty-folder": "^2.0.1",
"eslint": "^6.3.0",
"json-schema-to-typescript": "^11.0.1",
"nodemon": "^1.17.4",
"npm-run": "^5.0.1",
"rimraf": "^3.0.1",
"tsconfig-paths": "^4.0.0",
"typescript": "^4.2.3"
},我的.eslintrc.js
module.exports = {
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
extends: ["plugin:@typescript-eslint/recommended"],
rules: {
// note you must disable the base rule as it can report incorrect errors
indent: "off",
"@typescript-eslint/indent": ["error", 2],
"@typescript-eslint/explicit-function-return-type": [0],
"@typescript-eslint/no-explicit-any": [0],
"@typescript-eslint/no-unused-vars": [0],
"@typescript-eslint/camelcase": [0],
"@typescript-eslint/no-namespace": [0],
"@typescript-eslint/no-empty-interface": [
"error",
{
allowSingleExtends: true
}
],
"no-multiple-empty-lines": [
"error",
{
max: 1,
maxEOF: 1,
maxBOF: 0
}
],
"no-var": "error",
"newline-before-return": "error",
semi: [2],
"padding-line-between-statements": [
"error",
{ blankLine: "always", prev: "*", next: "if" },
{ blankLine: "always", prev: "*", next: "for" },
{ blankLine: "always", prev: "*", next: "switch" },
{ blankLine: "always", prev: "*", next: "while" },
{ blankLine: "always", prev: "*", next: "break" },
{ blankLine: "always", prev: "*", next: "try" }
],
"comma-dangle": ["error", "never"]
}
};发布于 2022-07-24 12:45:11
我升级到
"@typescript-eslint/eslint-plugin": "^5.26.0",
"@typescript-eslint/parser": "^5.26.0",
"typescript": "^4.7.2"来自Line 0: Parsing error: Cannot read property 'map' of undefined的Ty to Black答案
https://stackoverflow.com/questions/73098353
复制相似问题