Vite Ts

Vite TypeScript Vite only performs translation of.ts files and does not perform any type checking. Assume that type checking has been taken over by your IDE or build process (you can either run TSC –noEmit in your build script or install vuE-tsc and run VUE-tsc –noEmit to type check your *.vue files).

To synchronize with BuildScript, add vuE-tsc –noEmit before DevScript in your template project to turn on type checking

"scripts": {
    "dev": "vue-tsc --noEmit && vite"."build": "vue-tsc --noEmit && vite build"."serve": "vite preview"
},
Copy the code

Vscode Ts

Vscode comes with typescript support and also automatically enables typescript, lint only prettier, then turn eslint off (workspace disabled). Turn off the format function

"javascript.format.enable": false."typescript.format.enable": false."javascript.validate.enable": false.Copy the code

ESLint Prettier

Lint would just use prettier when vue- TSC tells us to use typescript native to vscode.

Vscode installed the prettier plug-in, leaving the project Lint script and the commit Lint.

lint scirpt

npm install --save-dev --save-exact prettier
Copy the code
"lint": "npx prettier --write ."
Copy the code

commit lint

npm install --save-dev husky lint-staged
npx husky install
npm set-script prepare "husky install" NPM remember to upgrade to 7.0
npx husky add .husky/pre-commit "npx lint-staged"
Copy the code
// package.json
{
  "lint-staged": {
    "* * / *": "prettier --write --ignore-unknown"}}Copy the code