What does the "typecheck" npm script in Vue projects using Vite and TS do?

Viewed 601

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 )

1 Answers

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. You can change the start to "tsc --noEmit if you want to check .ts files exclusively. Nevertheless this is a vital script and it should be run as much as possible, especially as part of your CI/CD build process.

Ref to the documentation.

Related