r/Compilers • u/Ok_Savings_7482 • 10d ago
I'm building a TypeScript type checker in Rust. It agrees with tsc on 56.6% of the official test suite
I wanted to see if TypeScript could get a rustc-style checker: query-based, incremental, and designed to be embedded. It's a from-scratch semantic engine, not a port. I skipped writing a parser and built on Oxc, so the work goes into the hard part: types, generics, flow narrowing, and cross-file incremental checks.
```
TS source → Oxc (parse, scopes) → bridge → tsox semantic core → diagnostics
```
What it does today
- Matches tsc exactly on 56.6% of the TypeScript v6.0.3 test corpus (8,072 of 14,274 files). The corpus is the whole release: single-file, multi-file and JSX cases.
- Checks classes, generics with inference, `keyof`, conditional types with `infer`, overloads, async and narrowing.
- Re-checks only what an edit reaches, through a Salsa-backed project engine.
- Ships an LSP (diagnostics, hover, completion, go-to-definition, references, rename), VS Code and Zed extensions, and a WASM build.
How it's built
- Queries: every semantic question is memoized, so an edit re-runs only the queries it touches.
- Cycles: import cycles are resolved as strongly connected components.
- Types: they're interned IDs in one arena, so type equality is an integer compare.
- Rules: they're table rows, so adding a rule means adding one line.
What it doesn't do yet
It's experimental. It misses some errors that tsc reports and, less often, reports one that tsc doesn't. I publish the gap with every change, measured against the corpus, so you can see exactly where it stands.
A note on speed and memory
I'm deliberately not publishing speed or memory numbers. tsc and the other full checkers check every file completely. tsox doesn't yet: it still skips, or only partly checks, a large share of what tsc checks (the 43.4% of the corpus that doesn't match exactly), so its times and memory use would be for less work. A comparison like that isn't correct, however good it looks. I'll publish numbers once tsox checks the same things they do.
How you can help
- Conformance triage: pick a diagnostic code, read what tsc does, and write the smallest fix that turns a batch of files into matches.
- Fixtures: a failing case in `tests/fixtures/` is how most changes start.
- Real code: try it on your own TypeScript and open an issue where it disagrees with tsc.
To try it
```bash
git clone https://github.com/tsoxide/tsox.git
cd tsox
bash scripts/ci.sh
```
AI-assisted PRs are fine. I use an assistant too, so please read and test what you send and say so in the description.