TypeScript版本不被typescript-eslint-parser官方支持

17

我继承了一个使用老旧工具AngularJs开发的应用程序,其中使用了遗留工具bowergrunt

当我运行grunt serve --reload命令时,会出现以下警告消息:

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

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

SUPPORTED TYPESCRIPT VERSIONS: ~2.3.2

YOUR TYPESCRIPT VERSION: 2.2.2

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

这很奇怪,因为我使用的是最新版本的Typescript:

tsc --version
Version 4.1.3

我假设您已经在本地安装了TypeScript。这是可能的吗?

我如何检查已安装的工具版本(tsceslint)?

如何升级?它值得升级吗?

编辑:依赖列表

> npm list
foo@16.17.12 /Users/llaporte/workspace/foo
├── @types/angular-animate@1.5.9
├── @types/angular-gettext@2.1.32
├── @types/angular-material@1.1.58
├── @types/angular-sanitize@1.3.7
├── @types/angular-ui-router@1.1.40
├── @types/angular@1.6.43
├── @types/es6-shim@0.31.35
├── @types/jasmine@2.8.6
├── @types/jquery@2.0.49
├── @types/ramda@0.25.51
├── @types/underscore.string@0.0.30
├── @types/underscore@1.8.7
├── @types/urijs@1.15.36
├── @typescript-eslint/eslint-plugin@4.14.2
├── @typescript-eslint/parser@4.14.2
├── grunt-bar@1.2.0 (git+http://xxx/xxx/grunt-bar.git#a6b7624aeea9ea324e92a9e8971feb67ab9d0346)
└── typescript@4.1.3

编辑:grunt 版本

我正在使用一个较旧的 grunt 版本:

> grunt --version
grunt-cli v0.1.13
grunt v0.4.5

它是一种永远不会消失的传染病。 - bvj
4个回答

21
// .eslintrc.json

"parserOptions": {
    "warnOnUnsupportedTypeScriptVersion": false
},

来源: Github问题评论


这样做可以禁用与Typescript版本相关的所有警告。 - Carmine Tambascia

4
这是一个旧问题,但仍然出现,因为您项目中的一些依赖项使用旧版本的。
`@typescript-eslint/******@***.***`

即使 CRA 仍然安装它,这并不意味着 CRA 或任何其他构建工具(如 webpack 或 grunt)都应该降级以使用该依赖项。相反,像 suggest 一样,并且对我有用的是,同时应该从任何仍在使用它的构建工具中删除/升级该库,可以将以下内容添加到 package.json 中:
"resolutions": {
  "@typescript-eslint/typescript-estree": "5.9.0"
}

基本上是告诉编译器使用 typescript-estree 的 5.9.0 版本,或者“升级”底层库。

-1

仓库维护者提供的解决方案是一种能力,这太荒谬了。就我个人而言,我只会回到普通的ESLint。这已经是我在两年内第三次整夜困扰于此问题。如果花费数小时才能找出如何安装npm包而不出现错误,或者必须忽略某些消息,那么肯定有问题,你不能说它已经被修复了。此外,如果你阅读仓库,他们并没有说已经修复,而是说我们将通过您能够找出所有正确版本以满足您的依赖关系来处理它。 - JΛYDΞV

-3
yarn add -D @typescript-eslint/typescript-estree

4
请将以下英文内容翻译成中文。内容与信息技术相关。只需要翻译文字内容,不要加入机器翻译的风格。请同时提供如何/为什么这有帮助的解释。 - greybeard

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接