停止打字稿编译器尝试编译Node_modules中的文件(SFPX React)

发布于 2025-01-29 00:10:36 字数 1072 浏览 3 评论 0 原文

我正在研究SPFX(SharePoint Framework)React应用程序。 在安装流行的AutomApper( @automapper/core @automapper/pojos)之后,我在 Gulp Build build

“

我的tsconfig.json看起来如下:

我正在使用Rush-Stack-Compiler 4.2,该4.2使用Typescript 4.2.4幕后。

我根据其他问题的答案尝试的事情:

  1. 升级打字稿版本 - 在SPFX中,这是通过将Rush-Stack-Compiler升级到4.2来完成的 这只会有所帮助,因为@AutomApper库中的类型错误较少,但并非所有这些错误都是固定的。
  2. 添加“ dublude”:[“ node_modules”] 添加到tsconfig.json
  3. add “ skiplibcheck”:true to tsconfig.json
  4. 指定的空“ empter” “ ] 在tsconfig.json中设置,

为什么TSC专门查看node_modules/@autoMapper文件夹,尽管Node_modules中有数百个带有 *.D.TS文件的其他文件夹,而不是问题?

I am working on an SPFX (SharePoint Framework) React application.
After installing the popular automapper for typescript (@automapper/core @automapper/pojos) I keep getting compiler errors during gulp build:

enter image description here

My tsConfig.json looks like the following:

enter image description here

I am using rush-stack-compiler 4.2 which is using typescript 4.2.4 behind the scenes.

Things I have tried based on the answers from other questions:

  1. Upgrade typescript version - in SPFX this is done by upgrading the rush-stack-compiler from 3.7 to 4.2
    This helped only a little, as there are LESS type errors from the @automapper library, but not all of them were fixed.
  2. Add "exclude": [ "node_modules" ] to the tsConfig.json
  3. Add "skipLibCheck": true to the tsConfig.json
  4. Specified empty "types": [] setting in tsConfig.json

Any idea why tsc is looking specifically into the node_modules/@automapper folder, although there are hundreds of other folders in node_modules with the *.d.ts files, that are not a problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

水溶 2025-02-05 00:10:36

尝试将打字稿更新为4.5: @Microsoft/Rush-stack-Compiler-4.5

看起来@Automatpper正在使用Bleeding-Edge-Edgecript标题功能。该问题与 node_modules 的包含/排除无关,它似乎与打字稿版本有关(您似乎已经安装了一个较旧的版本,该版本不了解自动应用程序的某些定义)。

或者,使用旧版本的汽车应用程序(7.x可能还可以)

Try updating typescript to 4.5: @microsoft/rush-stack-compiler-4.5

It looks like the @automatpper is using bleeding-edge typescript features. The problem is not related to inclusion/exclusion of the node_modules, it seems to be related to the typescript version (you seem to have installed an older version that does not understand some definitions of the automapper).

Alternatively, use an older version of the automapper (7.x should probably be okay)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文