create-react-app WARNING: You are currently running a version of TypeScript... react 17.x + react-scripts 4.x

7xzttuei  于 2个月前  发布在  React
关注(0)|答案(2)|浏览(39)

嗨,大家!
我想知道为什么我仍然看到这个问题,它可以追溯到2019年或更早的时间。
我使用当前版本的CRA(4.0.3)、React(17.x)和TypeScript(4.5.2)从头开始创建了一个新的项目。
我没有更新TypeScript - 它是由CRA安装的。
现在当我运行npm run build时,我看到了:

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

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.2.0

YOUR TYPESCRIPT VERSION: 4.5.2

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

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

我在两年前见过它,现在又出现了。
我不确定,但也许这个警告来自旧的@typescript-eslint/typescript-estree@3.10.1:

(master *+%)$ npm list @typescript-eslint/typescript-estree
lists-product@0.1.0 /projects/custom/piano/lists-product
└─┬ react-scripts@4.0.3
  ├─┬ @typescript-eslint/eslint-plugin@4.15.2
  │ └─┬ @typescript-eslint/experimental-utils@4.15.2
  │   └── @typescript-eslint/typescript-estree@4.15.2 deduped
  ├─┬ @typescript-eslint/parser@4.15.2
  │ └── @typescript-eslint/typescript-estree@4.15.2
  └─┬ eslint-plugin-testing-library@3.10.1
    └─┬ @typescript-eslint/experimental-utils@3.10.1
      └── @typescript-eslint/typescript-estree@3.10.1

它之所以存在是因为旧的eslint-plugin-testing-library@3.10.1(尽管有5.0.0版本)。而那个 - 是react-scripts安装的。
这是否意味着我们应该等待您的CRA更新以使用eslint-plugin-testing-library@5.0.0?

egdjgwm8

egdjgwm81#

Also getting this for linting,

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.5.0

YOUR TYPESCRIPT VERSION: 4.5.3

30byixjq

30byixjq2#

A selective version resolution 可以减轻这个警告,尽管存在不兼容的风险。(到目前为止,在我的项目中一切顺利。)
package.json 中:

"resolutions": {
    "@typescript-eslint/typescript-estree": "5.9.0"
  }

当然,正确的解决方法是更新上游依赖关系。

相关问题