“ Typecheck”是什么?使用VITE和TS在VUE项目中进行的NPM脚本?

发布于 2025-02-01 01:12:52 字数 227 浏览 0 评论 0原文

我使用TypeScript创建了一个新的VUE项目,并通过

npm init vue@最新

在软件包文件中

"typecheck": "vue-tsc --noEmit -p tsconfig.vitest.json --composite false",

。我应该使用此脚本来确保我的代码很好吗? (例如QA工作流程)

I created a new Vue project using TypeScript and Vite via

npm init vue@latest

Inside the package.json file there is a typecheck script

"typecheck": "vue-tsc --noEmit -p tsconfig.vitest.json --composite false",

but I don't know its purpose. Should I use this script to ensure that my code is fine? ( E.g. for QA workflows )

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

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

发布评论

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

评论(1

银河中√捞星星 2025-02-08 01:12:52

Vite Bundler不执行类型检查;因此,默认情况下 - 如果您的typescript代码中有任何错误 - vite不会像正常情况那样抱怨并将其转移(这是为什么它如此快的原因) 。

“ typecheck”脚本将按照其名称的建议进行,请检查.ts and .vue 错误通过vue-tsc -noemit命令文件。重要的是要了解此脚本不会注意更改,只运行一次
每个执行。但是,这是一个重要的脚本,应该尽可能地运行,尤其是作为CI/CD构建过程的一部分。

还值得注意的是,您可以将脚本的开始更改为“ TSC -noemit”到Typecheck .ts专门

。 ://vitejs.dev/guide/features.html#typescript“ rel =“ nofollow noreferrer”>文档。

Vite bundler does not perform type checking; so by default - if there are any errors in your TypeScript code - Vite will not complain and transpile it as normal (this is part of the reason why it is so fast).

The "typecheck" script will do as it's name suggests, check for any TypeScript errors in your .ts and .vue files via the vue-tsc --noEmit command. It is important to understand that this script will not watch for changes and only run once
per execution. Nevertheless, it is a vital script and should be run as much as possible, especially as part of your CI/CD build process.

It is also worth noting that you can change the start of the script to "tsc --noEmit to typecheck .ts files exclusively.

Ref to the documentation.

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