vue-tsc
The vue-tsc checker reports type errors in Vue single-file components and .ts files, using Vue Language Tools. Use it instead of the TypeScript checker in Vue projects.
Set up
Install
vue-tscand TypeScript. The checker supportsvue-tsc~2.2.10and^3.0.0, with TypeScript 5 or later.bashpnpm add -D vue-tsc typescriptbashnpm install -D vue-tsc typescriptbashyarn add -D vue-tsc typescriptbashbun add -d vue-tsc typescriptEnable the checker:
tsimport vue from '@vitejs/plugin-vue' import { defineConfig } from 'vite' import checker from 'vite-plugin-checker' export default defineConfig({ plugins: [ vue(), checker({ vueTsc: true, }), ], })
In dev mode, the checker uses the TypeScript watch API with the Vue language plugin. In build mode, it runs vue-tsc --noEmit.
Use a different tsconfig
By default, the checker looks for tsconfig.json in the Vite root. To use another file, set tsconfigPath:
checker({
vueTsc: {
tsconfigPath: 'tsconfig.app.json',
},
})Project references
Build mode (vue-tsc --build) turns on automatically when the tsconfig is solution-style: "files": [], no include, and at least one entry in references. create-vue generates this layout. To turn it on or off explicitly, set buildMode. Build mode works the same way as in the TypeScript checker.
Options
| Option | Type | Default | Description |
|---|---|---|---|
root | string | Shared root | Directory to resolve tsconfigPath from. |
tsconfigPath | string | 'tsconfig.json' | Path to the tsconfig file, relative to root. |
buildMode | boolean | true for solution-style tsconfigs, otherwise false | Run vue-tsc with --build. See Project references. |
