ts-r-check
Type checker. Replaces tsc.
- Pre-alpha
- Works from source
ts-r-check type-checks a TypeScript project and prints diagnostics in tsc’s format, with tsc’s error codes. It never writes JavaScript or declaration files: it is the tsc --noEmit step of a build. It is the least finished part of ts-r, and it follows one rule: no false positives first.
1.6× faster type checks
What switching looks like
Nothing is on npm yet. Once it is, switching looks like this: ts-r-check reads the config you already have, so the change is to the command, not the project.
"scripts": {
- "typecheck": "tsc --noEmit -p tsconfig.json",
+ "typecheck": "ts-r-check --noEmit -p tsconfig.json",
}
What works, and what doesn’t yet
Works today
- Loading the project from tsconfig.json, including extends, with tsc’s config diagnostics
- Module resolution that matches tsc’s on every resolution of the reference app
- Assignability, calls and overloads, generics and inference, unions and narrowing
- keyof, mapped, conditional and literal types; classes, declarations and unused-code checks
- tsc’s output in both plain and pretty form, with tsc’s exit codes
Not yet
- JSX element and attribute types
- Evolving arrays (let xs = [])
- Implicit any in binding patterns (TS7031) and this parameter checks
- Reverse mapped types
- TypeScript syntax errors in .js files (TS8xxx)
Measured
Every run, on the same reference app as the home page, with the command and commit that recorded it.
ts-r-check against tsc 7.0.2
Type checking five public projects from the command line, cold (no saved history), against TypeScript 7.0.2's native tsc. These repos do not type-check cleanly under TypeScript 7, and ts-r-check does not report the same diagnostics as tsc on them yet: it reports extra ones on all five (27 on date-fns to 1,333 on RxJS in the last comparison) and misses some of tsc's. It also skips checks it does not implement yet, so these times will move as the checker grows.
- ts-r
- Other tools
| Project | ts-r-check, saved history, nothing changed | The repo's own tsc |
|---|---|---|
| tRPC | 23 ms | 1,130 ms |
| date-fns | 78 ms | 324 ms |
| RxJS | 57 ms | 2,468 ms |
| TypeORM | 126 ms | 3,915 ms |
| Playwright | 40 ms | 4,754 ms |
How we measured
- Measured
- Wall time with hyperfine (cargo xtask bench --repos), median of 5 runs; peak RSS of one extra run. Every tool checks the same wrapper tsconfig (noEmit, not incremental)
- Machine
- Apple M-series MacBook (macOS arm64, 16 cores, 48 GB), shared with other jobs while measuring; release build, 4 threads
- Software
- ts-r-check release build; TypeScript 7.0.2 (native tsc) pinned in bench/package.json; each repo's own TypeScript
- Input
- tRPC, date-fns, RxJS, TypeORM and Playwright at the commits pinned in bench/repos.toml
- Command
cargo xtask bench --fetch-repos --repos trpc,date-fns,rxjs,typeorm,playwright && cargo xtask bench --repos trpc,date-fns,rxjs,typeorm,playwright --memory check-- Recorded in
- commit
9c3a371
Correctness
Compared with the tool ts-r-check replaces, on its own tests and on real code.
- Module resolution100%
63,958 of 63,958 resolutions match (0 differences)
Every resolution in tsc --traceResolution for 24 tsconfig files of private-app. Commit 856e43d.
- tsconfig loading100%
49 of 49 configs match tsc --showConfig exactly
private-app tsconfig files. Commit 856e43d.
- Binder diagnostics90.0%
398 of 442 tests match exactly; 1,683 of 1,789 expected diagnostics found
tsc 7.0.2 baselines for the binder's error codes. Commit 16a6b7e.
- Type checker58.0%
58.0% of 13,398 conformance test variants exact; 937 variants with a diagnostic tsc does not report
tsc 7.0.2 conformance baselines. Commit aaa5051.
Command line
An excerpt of ts-r-check --help. You can also run it through the launcher as ts-r check.
Next to tsc
ts-r-check reads the same tsconfig.json and prints the same format, so editor problem matchers and CI annotations that parse tsc’s output work unchanged. An error from ts-r-check is very likely one tsc reports too, but a clean run doesn’t mean tsc is clean. Keep tsc in CI until ts-r-check covers the features your project uses.
usage: ts-r-check -p tsconfig.json [--noEmit] [--pretty false] [--threads N]