为什么类型错误阻止UI

发布于 2025-02-12 11:58:31 字数 392 浏览 1 评论 0原文

该UI均由此黑屏幕显示错误,我想仅在

编译终端中查看类型错误:

我启动了一个使用TypeScript的新创建React应用程序,对于任何类型错误, 45

TS2322:类型“布尔值”不可分配给'字符串'。 8 | 9 |

10 | <路由路径=“/product”元素= {hi}> | ^^ 11 | 12 | </> 13 | );

在此处输入图像描述

有什么方法可以解决此问题吗?

I started a new create react app with typescript and for any type error, the ui is covered by this black screen showing errors, i want to see type errors only in terminal

Compiled with problems:X

ERROR in src/App.tsx:10:45

TS2322: Type 'boolean' is not assignable to type 'string'.
8 |
9 |

10 | <Route path="/product" element={hi}>
| ^^
11 |
12 | </>
13 | );

enter image description here

Any way to fix this?

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

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

发布评论

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

评论(1

不必了 2025-02-19 11:58:31

假设您正在使用Create-React-App,

1-如果您想忽略整个项目。在项目的根部创建一个“ .env”文件,并将这些设置放入其中。

TSC_COMPILE_ON_ERROR=true
ESLINT_NO_DEV_ERRORS=true

2-如果您只想忽略那条线。在线上方提出了这一评论。

// @ts-ignore

Assuming you are using create-react-app,

1- If you want to ignore for whole project. Create a ".env" file in the root of the project and put inside it these settings.

TSC_COMPILE_ON_ERROR=true
ESLINT_NO_DEV_ERRORS=true

2-If you want to ignore just that line. Just above the line put this comment.

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