svelte-check
The svelte-check checker runs svelte-check, which reports type errors, Svelte compiler warnings, and accessibility warnings in Svelte components and .ts files.
Set up
Install
svelte-check(version 4 or later) and TypeScript:bashpnpm add -D svelte-check typescriptbashnpm install -D svelte-check typescriptbashyarn add -D svelte-check typescriptbashbun add -d svelte-check typescriptEnable the checker:
tschecker({ svelteCheck: true, })
In dev mode, the checker runs svelte-check --watch from the Vite root. In build mode, it runs svelte-check.
Pass flags to svelte-check
Use flags to pass svelte-check CLI flags, for example to choose a tsconfig:
ts
checker({
svelteCheck: {
flags: '--tsconfig ./tsconfig.app.json',
},
})In dev mode, the checker manages --watch, --preserveWatchOutput, and --output itself, so those flags only apply in build mode. --workspace applies in both modes and defaults to the Vite root.
Options
| Option | Type | Default | Description |
|---|---|---|---|
flags | string | '' | CLI flags for svelte-check. |
dev.logLevel | ('error' | 'warning')[] | ['error', 'warning'] | Diagnostic levels to report in dev mode. |
