警告:您当前运行的 TypeScript 版本不受 @typescript-eslint/typescript-estree 官方支持

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

您好,我的终端出现一些错误,它说我需要使用 4.4.0 版本,而我当前的版本是...

在我的项目中,我当前的打字稿版本如下所示,

    "typescript": "^4.4.2",
    "typedoc": "^0.21.8",
    "react-scripts": "^3.4.4",
    "@typescript-eslint/eslint-plugin": "^4.29.3",
    "@typescript-eslint/parser": "^4.29.3",

此外,当我尝试运行 npm run dev 命令或 npx eslint . 时,错误会向我显示,如下所示,

    =============

   WARNING: You are currently running a version of TypeScript which is not 
   officially supported by @typescript-eslint/typescript-estree.

    You may find that it works just fine, or you may not.

   SUPPORTED TYPESCRIPT VERSIONS: >=3.3.1 <4.4.0

   YOUR TYPESCRIPT VERSION: 4.4.2

     Please only submit bug reports when using the officially supported 
    version.

    =============

我该如何解决这个问题,我在谷歌上做了很多研究,但没有任何效果。这对我来说会有很大的帮助。

reactjs typescript ubuntu warnings react-scripts
7个回答
34
投票

我也在为同样的警告而苦苦挣扎。通过运行以下命令将 eslint 和相关软件包更新到最新版本来解决这个问题:

npm i eslint@latest @typescript-eslint/parser@latest @typescript-eslint/eslint-plugin@latest --save

现在,我的 package.json 中有以下版本,并且我不再收到警告

"eslint": "^8.38.0",
"eslint-config-google": "^0.14.0",
"eslint-plugin-import": "^2.22.0",
"typescript": "^5.0.4"

15
投票

我不会降级我的 Typescript,因为你会错过更新的 TS 功能 - 我会找到一种方法来更新

@typescript-eslint/typescript-estree

您可能没有直接安装它,这可能是另一个包的依赖项,例如,

@typescript-eslint/experimental-utils
@typescript-eslint/eslint-plugin
的依赖项,因此请在您的
yarn.lock / package.lock
文件中跟踪父包并碰撞它,结果它也应该碰撞
@typescript-eslint/typescript-estree


3
投票

就我而言,这个问题已经过时了

eslint-config-next
。除了更新
@typescript-eslint/parser
@typescript-eslint/eslint-plugin
之外,请确保也更新它。


1
投票

我使用的是yarn,所以我在package.json中使用

@typescript-eslint/typescript-estree
增加了
resolutions
的版本,并且警告消失了。 npm 好像可以用
overrides
.

package.json

  "resolutions": {
    "@typescript-eslint/typescript-estree": "^5.59.2"
  },

0
投票

尝试删除 yarn.log 文件并重新运行 npm install。这对我有用。


-1
投票

为了未来。你只需要把typescript版本修复为fixed即可。也许最新版本的 @typescript-eslint...不支持您的 TS 版本。


-8
投票

尝试使用>=3.3.1之间的打字稿版本<4.4.0. 在这里您有可用的打字稿版本列表。

更改版本后,删除 node_modules 文件夹和 package-lock.json 文件。然后执行

npm install

© www.soinside.com 2019 - 2024. All rights reserved.