Type Complexity

TypeScript type-checking cost of job type definitions across chain shapes and sizes.

Each scenario is generated as its own project and type-checked against Queuert's prebuilt .d.mts declarations. Every scenario carries one attempt middleware, so the baseline is a realistic client.

Test setup

  • Machine
    Apple M1 Pro
  • Runtime
    Node.js v24
  • Compilers
    TypeScript 6.0.2, TypeScript 7.0.2 and tsrs 0.20.1
    The last JavaScript-based tsc, the native compiler, and an experimental Rust port of the TypeScript 7.1 beta checker.
  • Runs
    3 per scenario
    The best time counts.

Scenario families

  • Linear
    Straight continueWith chains of 1 to 100 job types.
  • Branched
    Tree-shaped chains of varying width and depth.
  • Blockers
    Chains with up to three cross-chain blocker dependencies per step.
  • Loop
    Chains where every step can continue back to itself through a union.
  • Merge
    Slices of 50 job types merged into one client, up to 2,500 types.
  • Middleware
    The 100-type linear chain with up to 10 attempt middleware.

Results

Beyond a fixed baseline, cost grows roughly linearly with the number of job types whatever the chain's shape.

Type-check time, TS 6

ms
  • Linear: 1 type
    ~560
  • Linear: 10 types
    ~583
  • Linear: 50 types
    ~687
  • Linear: 100 types
    ~837
  • Branched: 4w x 3d
    ~792
  • Branched: 2w x 6d
    ~918
  • Blockers: 8 steps
    ~664
  • Blockers: 25 steps
    ~904
  • Loop: 20 steps
    ~618
  • Loop: 50 steps
    ~689
  • Merge: 2 x 50
    ~812
  • Merge: 5 x 50
    ~1,093
  • Merge: 10 x 50
    ~1,537
  • Merge: 20 x 50
    ~2,425
  • Merge: 50 x 50
    ~5,246
  • Middleware: 10 on linear-100
    ~854

Type-check time, TS 7

ms
  • Linear: 1 type
    ~115
  • Linear: 10 types
    ~118
  • Linear: 50 types
    ~137
  • Linear: 100 types
    ~158
  • Branched: 4w x 3d
    ~148
  • Branched: 2w x 6d
    ~165
  • Blockers: 8 steps
    ~134
  • Blockers: 25 steps
    ~182
  • Loop: 20 steps
    ~122
  • Loop: 50 steps
    ~139
  • Merge: 2 x 50
    ~187
  • Merge: 5 x 50
    ~217
  • Merge: 10 x 50
    ~328
  • Merge: 20 x 50
    ~540
  • Merge: 50 x 50
    ~1,419
  • Middleware: 10 on linear-100
    ~173

Type-check time, tsrs

ms
  • Linear: 1 type
    ~72
  • Linear: 10 types
    ~71
  • Linear: 50 types
    ~78
  • Linear: 100 types
    ~85
  • Branched: 4w x 3d
    ~80
  • Branched: 2w x 6d
    ~88
  • Blockers: 8 steps
    ~75
  • Blockers: 25 steps
    ~87
  • Loop: 20 steps
    ~69
  • Loop: 50 steps
    ~75
  • Merge: 2 x 50
    ~77
  • Merge: 5 x 50
    ~94
  • Merge: 10 x 50
    ~124
  • Merge: 20 x 50
    ~180
  • Merge: 50 x 50
    ~426
  • Middleware: 10 on linear-100
    ~86

The TypeScript 7 instantiation count of each scenario, with its job type count and the scaling against the one-type baseline.

Instantiations, TS 7

instantiations
  • Linear: 1 type1 type · 1.0x baseline
    20,015
  • Linear: 10 types10 types · 1.3x baseline
    25,019
  • Linear: 50 types50 types · 2.4x baseline
    47,219
  • Linear: 100 types100 types · 3.7x baseline
    74,969
  • Branched: 4w x 3d85 types · 3.3x baseline
    66,980
  • Branched: 2w x 6d127 types · 4.5x baseline
    90,458
  • Blockers: 8 steps30 types · 2.2x baseline
    44,150
  • Blockers: 25 steps98 types · 6.5x baseline
    129,643
  • Loop: 20 steps21 types · 1.6x baseline
    31,706
  • Loop: 50 steps51 types · 2.4x baseline
    48,806
  • Merge: 2 x 50100 types · 4.0x baseline
    79,234
  • Merge: 5 x 50250 types · 8.1x baseline
    161,203
  • Merge: 10 x 50500 types · 14.9x baseline
    298,630
  • Merge: 20 x 501,000 types · 28.7x baseline
    574,112
  • Merge: 50 x 502,500 types · 70.6x baseline
    1,413,540
  • Middleware: 10 on linear-100100 types · 3.9x baseline
    77,084

Reproduce

From benchmarks/type-complexity. The generated scenarios stay in generated/ for inspection.

Terminal

pnpm --filter benchmark-type-complexity start
pnpm --filter benchmark-type-complexity start:ts7
pnpm --filter benchmark-type-complexity start:tsrs
esc

Search guides, integrations and every exported symbol.

↑ ↓ to navigate↵ to open