How tsox was built
tsox was built in small, ordered steps. Each step added one capability, came with its own tests and left a document that tells it as plan, issue, change and gain. This page is the map: the order the steps were taken in, what each one is guarded by, and where its document is.
The names describe capabilities, not release versions. The numbers only show the order.
The three rules behind the order
Most choices in the steps below follow from three priorities, in this order. The full argument is in the case study.
- A wrong error is worse than a missing one. A checker that reports a false error loses trust. When it cannot decide, it keeps the wider type, drops the narrowing, or says nothing.
- Agree with
tsc, measured. Every fixture runs through realtsc --strictand through tsox, and CI fails if the number of false positives rises. See testing. - Keep the common path cheap. Arena ids, interning and small inline stacks keep a large file inexpensive, but a design that is fast and wrong loses to rule 1.
Part 1: One file at a time
The first seven steps build a checker for a single file: primitives, objects, literals, narrowing, classes, expressions and parameters.
A checker that agrees with tsc on a single file, built on an arena of type ids.
- 1
The end-to-end checker: primitive types, basic functions, diagnostics, and honest handling of what is not supported yet.
Guarded by
tests/foundation.rs - 2
Objects, arrays, unions, aliases, interfaces, declaration resolution, structural subtyping and function arity.
Guarded by
tests/structural_types.rs - 3
Keep literal information while modelling how it widens.
Guarded by
tests/literal_widening.rs - 4
Refine types across branches and flow paths.
Guarded by
tests/control_flow_narrowing.rs - 5
Class members, constructors, inheritance, static state and `this`.
Guarded by
tests/classes_inheritance.rs - 6
Expression inference, calls, members, logical operations, loops, switches, assertions and program-level checking.
Guarded by
tests/expression_program_checking.rs - 7
Parameter metadata and binding and destructuring semantics.
Guarded by
tests/parameters_destructuring.rs
Part 2: Generics and flow
Generic inference and complete narrowing decide how much of everyday TypeScript the checker can follow, so they came before any project-scale work.
The two areas that decide how much of real TypeScript the checker can follow.
- 8
Type parameters on functions, interfaces, aliases and classes: inference, substitution, constraints, defaults, explicit type arguments, recursive shapes and builtin generics.
Guarded by
tests/generics_tier1.rstests/generics_tier2.rstests/generic_classes.rstests/recursive_types.rs - 9
Joins, discriminated unions, `in` and `instanceof`, and `CheckSession` for file identity and metrics.
Guarded by
tests/narrowing_advanced.rstests/narrowing_complete.rstests/check_session.rs
Part 3: From one file to a project
Imports first, then a sturdier core (incremental state, declaration slots, intersections), then the identity that lets a declaration cross files, and finally the engine that checks a whole project and re-checks only what a change reaches.
Imports, a sturdier core, and an engine that checks a set of files and re-checks only what a change reaches.
- 10
Resolve imports with `oxc_resolver`, build a graph indexed by `FileId`, detect cycles, order files into dependency layers and check a project in parallel. Behind the `module-resolution` feature.
Guarded by
tests/module_resolution.rs - 11
Salsa, a bump scratchpad that takes only `Copy` values, and mimalloc, each behind its own feature.
- 12
Interfaces, classes and object-literal aliases become `Ref` slots that are never rewritten; a name lives on a `Named` or `App` node instead of on an id.
- 13
`A & B` with ordered identity, lazy reduction of discriminant conflicts, relations, member access, calls and generics.
Guarded by
tests/intersection_types.rstests/intersection_overloads.rs - 14
A declaration gets an identity that survives a run and moves between arenas as data; imports are diagnosed against complete export lists and cycles are checked until their exports settle.
Guarded by
tests/unit_exports.rstests/unit_imports.rstests/project_imports.rstests/import_diagnostics.rs - 15Project EngineCurrent baseline
A ready-queue scheduler, partial export lists with named reasons, cycles settled as one unit, `tsconfig.json` as a graph input, globals and library members, limits that report instead of guessing, and a query layer for incremental and watch mode.
Guarded by
tests/scheduler.rstests/scc_contract.rstests/project_config.rstests/incremental_project.rs
The order inside the project engine
The last step was itself built in an order, and the order was deliberate. Each part waited for the contract it depends on. The project engine page has the reasoning and the exit gate.
- Measure partial results first. Evidence before redesign.
- Fix the unit contract before the scheduler. Whether a cycle is one unit decides what a scheduler schedules. See cycles and settlement.
- Then the scheduler and the pipeline. Dependency counts, deterministic publication, cancellation, one read per file. See scheduler.
- Configuration beside it. It removes errors caused by incomplete project inputs. See project configuration.
- Library and ambient declarations. Names that are not imported, independent of file order. See library and ambient declarations.
- The query layer, last of the structure. Reuse needs stable units and stable publication, or a cache serves stale answers. See query layer.
- Safety throughout. A recursion guard added late would have to be added to every walk at once. See safety net and limits.
What every step leaves behind
- A test suite named after the milestone, so a contributor can tell what it covers from the file name alone.
- A document in the voice of a case study: what was planned, the issue found, what was changed and what it gained.
- A row in the milestone table of the documentation index.
Later work extends these steps instead of adding a new one. The suites for advanced narrowing, generic bounds, sessions and unreachable code are listed under the milestones table in the documentation index.
Where the work goes next
The steps above are done. What is open is tracked in two places: