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.

Check one app, wall timeShorter is faster. Pre-release build, real app.
  • ts-r-check0.01–0.04 s
  • tsc 7.0.20.15–0.17 s

3.8× 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.

package.json
  "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 private-app's three apps (api, web and worker) from the command line. ts-r-check reports no error tsc does not report on these apps and reproduces 2,638 of tsc's 2,792 diagnostics exactly; it is still missing some checks (binding-pattern implicit any, JSX attribute types), so it does a little less work than tsc. The source gives a range across the three apps and does not record the number of runs.

Check one app, wall timeShorter is faster, in s
  • ts-r
  • Other tools
  • ts-r-check0.01–0.04 s
  • tsc 7.0.20.15–0.17 s
Check one app, memoryShorter is faster, in MB
  • ts-r
  • Other tools
  • ts-r-check29–50 MB
  • tsc 7.0.2106–132 MB

Conformance against tsc 7's own tests is 58.0% exact (13,398 variants, commit aaa5051); see Compatibility and status in the docs.

How we measured
Measured
Wall time and peak memory of ts-r-check -p and tsc -p on each app; the bars show the upper end of the range. Number of runs not recorded.
Machine
Not recorded with the result. ts-r's measured runs so far are on the project's Apple M-series development Mac (macOS arm64, release build).
Software
ts-r-check release build; TypeScript 7.0.2 (native tsc)
Input
private-app apps/api, apps/web and apps/worker
Command
target/release/ts-r-check -p apps/web --pretty false against tsc -p apps/web (see crates/ts_r_checker/AGENTS.md, Oracles)
Recorded in
commit 5f07193

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.

ts-r-check --help
usage: ts-r-check -p tsconfig.json [--noEmit] [--pretty false] [--threads N]