语法错误:import_typescript.default.isTokenKind 不是函数(0:未定义)

问题描述 投票:0回答:1

我在尝试构建项目时在生产管道中遇到了上述错误。它在本地正确构建。 它似乎与 ESLint 问题有关。

我最近将此 React 应用程序从使用 React 版本 16 更新为 18。升级后,我遇到了与以下版本的 ESLint 依赖项相关的一些问题(此依赖项与 React 16 一起使用。)

"@typescript-eslint/eslint-plugin": "^4.6.0",
"@typescript-eslint/parser": "^4.6.0",
"eslint-plugin-react": "^7.21.5",

但是,将它们升级到下面提到的版本(最新版本)后,我现在遇到如上所述的导入错误。

如果需要更多信息,请评论...

package.json

{
  "name": "app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@emotion/react": "^11.11.1",
    "@emotion/styled": "^11.11.0",
    "@hookform/resolvers": "^3.3.0",
    "@mui/material": "^5.14.5",
    "@reduxjs/toolkit": "^1.9.5",
    "@testing-library/jest-dom": "^5.11.4",
    "@testing-library/react": "^11.1.0",
    "@testing-library/user-event": "^12.1.10",
    "axios": "^0.21.1",
    "bootstrap": "^4.5.3",
    "buffer": "^6.0.3",
    "env-cmd": "^10.1.0",
    "highlight.js": "^10.7.0",
    "immutability-helper": "^3.1.1",
    "immutable": "^4.0.0-rc.12",
    "localforage": "^1.9.0",
    "localforage-driver-memory": "^1.0.5",
    "lodash": "^4.17.20",
    "minio": "^7.0.18",
    "moment": "^2.29.1",
    "query-string": "^6.13.7",
    "rc-tree": "^4.0.0",
    "react": "^18.2.0",
    "react-avatar-editor": "^13.0.0",
    "react-beautiful-dnd": "^13.1.1",
    "react-bootstrap": "^1.4.0",
    "react-dom": "^18.2.0",
    "react-file-drop": "^3.1.2",
    "react-grid-dropdown": "^0.3.1",
    "react-hook-form": "^7.45.4",
    "react-moment": "^1.0.0",
    "react-overlays": "^4.1.1",
    "react-quill": "^2.0.0",
    "react-redux": "^8.1.2",
    "react-ripples": "^2.2.1",
    "react-rnd": "^10.2.4",
    "react-router-dom": "^5.2.0",
    "react-scripts": "5.0.1",
    "react-select": "^5.7.4",
    "react-spinners": "^0.13.8",
    "react-split-pane": "^2.0.3",
    "react-table": "^7.6.1",
    "react-textarea-autosize": "^8.3.3",
    "react-toastify": "^6.0.9",
    "styled-components": "^5.2.1",
    "styled-icons": "^10.22.0",
    "typescript": "^4.9.5",
    "uuid": "^8.3.1",
    "web-vitals": "^2.1.4",
    "yup": "^0.29.3"
  },
  "scripts": {
    "start": "env-cmd -f .env.development react-scripts start",
    "start_local": "env-cmd -f .env.local react-scripts start",
    "build:production": "env-cmd -f .env.production react-scripts build",
    "build:staging": "env-cmd -f .env.staging react-scripts build",
    "build": "env-cmd  -f .env.development react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "format": "prettier --write \"src/**/*.{ts,tsx}\"",
    "lint": "eslint --ext tsx,ts src --fix"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "@babel/plugin-proposal-private-property-in-object": "^7.21.11",
    "@types/jest": "^26.0.15",
    "@types/lodash": "^4.14.165",
    "@types/minio": "^7.0.7",
    "@types/node": "^12.0.0",
    "@types/react": "^18.2.21",
    "@types/react-avatar-editor": "^13.0.0",
    "@types/react-beautiful-dnd": "^13.1.4",
    "@types/react-bootstrap": "^0.32.30",
    "@types/react-dom": "^18.2.7",
    "@types/react-router-dom": "^5.3.3",
    "@types/react-table": "^7.0.25",
    "@types/styled-components": "^5.1.4",
    "@types/webpack-env": "^1.15.3",
    "@types/yup": "^0.29.14",
    "@typescript-eslint/eslint-plugin": "^6.7.0",
    "@typescript-eslint/parser": "^6.7.0",
    "eslint-plugin-react": "^7.33.2",
    "husky": "^4.3.0",
    "prettier": "^2.0.5"
  },
  "husky": {
    "hooks": {
      "pre-commit": "yarn lint"
    }
  }
}

.eslintrc.json

{
    "env": {
        "browser": true,
        "es6": true,
        "jest": true
    },
    "extends": [
        "eslint:recommended",
        "plugin:react/recommended",
        "plugin:@typescript-eslint/eslint-recommended"
    ],
    "globals": {
        "Atomics": "readonly",
        "SharedArrayBuffer": "readonly"
    },
    "parser": "@typescript-eslint/parser",
    "parserOptions": {
        "ecmaFeatures": {
            "jsx": true
        },
        "ecmaVersion": 11,
        "sourceType": "module"
    },
    "plugins": [
        "react",
        "@typescript-eslint"
    ],
    "rules": {
        "no-unused-vars": "off",
        "@typescript-eslint/no-unused-vars": "error",
        "react/prop-types": "off",
        "react/display-name": "off",
        "no-debugger": "off",
        "no-prototype-builtins": "off"
    },
    "settings": {
        "react": {
            "version": "detect"
        }
    }
}
javascript reactjs typescript frontend bitbucket-pipelines
1个回答
0
投票

只需将你的打字稿升级到 5.0.4

npm i -D [email protected]
© www.soinside.com 2019 - 2024. All rights reserved.