svelte-typecheck
v0.8.0
Published
A drop-in svelte-check replacement: up to 11× faster, zero dependencies.
Readme
svelte-typecheck
A drop-in svelte-check replacement: up to 11× faster, zero dependencies.
svelte-typecheck type-checks Svelte components with bun check, tsrs,
tsgo or tsc.
It takes the same options and prints the same output,
but runs a command-line checker on the components instead of
TypeScript's language service, which makes it up to 11 times faster.
It runs on Node 22+ or Bun.
- "check": "svelte-check --tsconfig ./tsconfig.json"
+ "check": "svelte-typecheck --tsconfig ./tsconfig.json"A cold run on carbon-components-svelte (1,200+ components) takes:
| Checker | Time | vs. svelte-check |
| :-------------------- | :----- | :--------------- |
| svelte-check | 40.5 s | 1× |
| TypeScript 6 (tsc) | 18.9 s | 2.1× |
| TypeScript 7 (tsgo) | 7.9 s | 5.1× |
| tsrs | 3.7 s | 11.1× |
| bun check | 3.6 s | 11.3× |
The benchmarks have more, including runs after a change.
--watch checks each save again, and Ctrl-C says what the last
check found.
Quick start
bun add -d svelte-typecheck
bunx svelte-typecheckIt exits with 1 when there's an error, 0 otherwise, and 2 when called wrong, such as with an unknown option.
CLI
# Check the project with the nearest tsconfig and the project's TypeScript
svelte-typecheck
# Check with another checker
svelte-typecheck --checker tsgo
svelte-typecheck --checker tsrs
svelte-typecheck --checker bun
# Check part of a project
svelte-typecheck --workspace packages/ui
svelte-typecheck --tsconfig ./tsconfig.app.json
svelte-typecheck --components "src/lib/**/*.svelte"
# Check every component, without a tsconfig, skipping two folders
svelte-typecheck --no-tsconfig --ignore dist,build
# Print one line per diagnostic, which is easier for scripts to read
svelte-typecheck --output machine
# Annotate a PR's diff from GitHub Actions
svelte-typecheck --output github
# Print each problem with its code and source lines, for a coding agent.
# This is the default under Claude Code, Codex, or with AGENT set.
svelte-typecheck --output agent
# Print errors only, or fail on warnings as well
svelte-typecheck --threshold error
svelte-typecheck --fail-on-warnings
# Ignore one compiler warning
svelte-typecheck --compiler-warnings a11y_missing_attribute:ignore
# Check types only, without compiling, when a linter such as svelte-lint
# reports the compiler's warnings
svelte-typecheck --diagnostic-sources js
# Report only files changed from HEAD, or since the branch left main, and the files that import them
svelte-typecheck --changed
svelte-typecheck --since origin/main
# Record the current diagnostics, then report only new ones
svelte-typecheck --baseline errors.json --update-baseline
svelte-typecheck --baseline errors.json
# Also fail when fixed diagnostics are still in the baseline
svelte-typecheck --baseline errors.json --strict-baseline
# Check again on every change
svelte-typecheck --watch
# Also check pages in the config's other extensions, such as .md
svelte-typecheck --pages
# Pass the checker its own flags after --
svelte-typecheck --checker tsrs -- --fast # tsrs's fast mode
svelte-typecheck --checker tsrs -- --maxMemory 4G # cap tsrs's memory
svelte-typecheck --checker tsgo -- --checkers 8 # 8 checker threads
svelte-typecheck --checker bun -- --threads 4 # 4 bun check threads
svelte-typecheck -- --noUncheckedIndexedAccess # a stricter option, without editing the tsconfig
svelte-typecheck -- --generateTrace trace # a trace of where the checker spends its time
svelte-typecheck --checker tsrs -- --fast --checkers 8 # several flags, in order
# Run on a process kept alive between runs, for agents and hooks
svelte-typecheck --daemon
# Ignore the cache from earlier runs
svelte-typecheck --no-incrementalAPI
import { typecheck } from "svelte-typecheck";
const { diagnostics } = await typecheck({ checker: "tsgo" });
for (const d of diagnostics) {
// file is absolute; line and column are 1-based, in the .svelte source
console.log(
`${d.file}:${d.line}:${d.column} ${d.severity} ${d.code} ${d.message}`,
);
}