Getting started
This guide adds TypeScript type checking to an existing Vite project. The steps are the same for the other checkers; only the packages you install and the option you set change.
Prerequisites
- A Vite project that meets the requirements
- A
tsconfig.jsonin the project root
Install and configure
Install vite-plugin-checker and TypeScript as dev dependencies:
bashpnpm add -D vite-plugin-checker typescriptbashnpm install -D vite-plugin-checker typescriptbashyarn add -D vite-plugin-checker typescriptbashbun add -d vite-plugin-checker typescriptAdd the plugin to your Vite config and enable the
typescriptchecker:ts// vite.config.ts import { defineConfig } from 'vite' import checker from 'vite-plugin-checker' export default defineConfig({ plugins: [ checker({ typescript: true, }), ], })The plugin is also available as a named export,
import { checker } from 'vite-plugin-checker'.Start the dev server:
bashnpx viteType errors appear in the terminal. Open the app in a browser to see them in the overlay as well.
Run a production build:
bashnpx vite buildtscruns alongside the build. If it reports an error, the build fails withtsc's exit code.
Enable more checkers
Set one option per checker. This example runs TypeScript and ESLint together:
// vite.config.ts
import { defineConfig } from 'vite'
import checker from 'vite-plugin-checker'
export default defineConfig({
plugins: [
checker({
typescript: true,
eslint: {
lintCommand: 'eslint "./src/**/*.{ts,tsx}"',
},
}),
],
})Some checkers accept true, and others need a configuration object. The checkers overview lists which is which.
Next steps
- Checkers overview: set up the checker that fits your project.
- Dev and build modes: learn how checks run and how they affect your build.
- Vitest: optional; skip the checkers when Vitest loads your Vite config.
