Skip to content

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.

  1. 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.
  2. Agree with tsc, measured. Every fixture runs through real tsc --strict and through tsox, and CI fails if the number of false positives rises. See testing.
  3. 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. 1

    The end-to-end checker: primitive types, basic functions, diagnostics, and honest handling of what is not supported yet.

    Guarded bytests/foundation.rs

  2. 2

    Objects, arrays, unions, aliases, interfaces, declaration resolution, structural subtyping and function arity.

    Guarded bytests/structural_types.rs

  3. 3

    Keep literal information while modelling how it widens.

    Guarded bytests/literal_widening.rs

  4. 4

    Refine types across branches and flow paths.

    Guarded bytests/control_flow_narrowing.rs

  5. 5

    Class members, constructors, inheritance, static state and `this`.

    Guarded bytests/classes_inheritance.rs

  6. 6

    Expression inference, calls, members, logical operations, loops, switches, assertions and program-level checking.

    Guarded bytests/expression_program_checking.rs

  7. 7

    Parameter metadata and binding and destructuring semantics.

    Guarded bytests/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.

  1. 8

    Type parameters on functions, interfaces, aliases and classes: inference, substitution, constraints, defaults, explicit type arguments, recursive shapes and builtin generics.

    Guarded bytests/generics_tier1.rstests/generics_tier2.rstests/generic_classes.rstests/recursive_types.rs

  2. 9

    Joins, discriminated unions, `in` and `instanceof`, and `CheckSession` for file identity and metrics.

    Guarded bytests/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.

  1. 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 bytests/module_resolution.rs

  2. 11

    Salsa, a bump scratchpad that takes only `Copy` values, and mimalloc, each behind its own feature.

  3. 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.

  4. 13

    `A & B` with ordered identity, lazy reduction of discriminant conflicts, relations, member access, calls and generics.

    Guarded bytests/intersection_types.rstests/intersection_overloads.rs

  5. 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 bytests/unit_exports.rstests/unit_imports.rstests/project_imports.rstests/import_diagnostics.rs

  6. 15
    Project 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 bytests/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.

  1. Measure partial results first. Evidence before redesign.
  2. Fix the unit contract before the scheduler. Whether a cycle is one unit decides what a scheduler schedules. See cycles and settlement.
  3. Then the scheduler and the pipeline. Dependency counts, deterministic publication, cancellation, one read per file. See scheduler.
  4. Configuration beside it. It removes errors caused by incomplete project inputs. See project configuration.
  5. Library and ambient declarations. Names that are not imported, independent of file order. See library and ambient declarations.
  6. The query layer, last of the structure. Reuse needs stable units and stable publication, or a cache serves stale answers. See query layer.
  7. 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:

  • the work plan, which breaks the remaining work into ten workstreams, W1 to W10, with the status of each;
  • the roadmap, which lists the next items in the order the evidence suggests.

MIT OR Apache-2.0