首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >类型赋值元组类型抛出解析错误:无法读取未定义属性(读取“map”)

类型赋值元组类型抛出解析错误:无法读取未定义属性(读取“map”)
EN

Stack Overflow用户
提问于 2022-07-24 12:19:33
回答 1查看 126关注 0票数 1

当我尝试这样的事情

代码语言:javascript
复制
const d: [number, number] = [1, 2];

我得到ts错误:解析错误:无法读取未定义(读取‘map’)属性

是什么导致了这个问题?

  • 根据需要添加了json和tslint包,告诉我是否需要为您的回答添加更多信息

package.json

代码语言:javascript
复制
  "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

代码语言:javascript
复制
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"]
  }
};
EN

回答 1

Stack Overflow用户

发布于 2022-07-24 12:45:11

我升级到

代码语言:javascript
复制
 "@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答案

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73098353

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档