Skip to main content

TypeScript analyzer

Compile-Cost Hotspots

Ingests a user-generated `tsc --generateTrace` output and attributes type-checking time to the files that dominate it. Strictly opt-in — Vipr never spawns tsc.

patterns ts-compile-trace

Compile-Cost Hotspots

Ingests a user-generated `tsc --generateTrace` output and attributes type-checking time to the files that dominate it. Strictly opt-in — Vipr never spawns tsc.

Type-checking time is a real cost every build and editor interaction pays, and nothing in per-file syntax can measure it. Rather than guessing "this type looks expensive", this family reads the compiler's own trace: generate one with tsc --generateTrace <dir> and point typescript.traceDir in vipr.config.json at it. Hotspots usually mark expensive conditional/mapped types, very wide imports, or intersection-heavy hierarchies.

Severity guide

info
Every hotspot is informational: measured cost, not wrongdoing.
warning
Not emitted by this family.
critical
Not emitted by this family.

Examples

Before

// trace attributes 2400ms of check time to one file of nested conditional types

After

// after: named intermediate types + interface extends; 300ms

Interfaces are flattened and cached by the checker; deeply nested conditional and intersection types are recomputed.

Remediation

Profile with @typescript/analyze-trace, then simplify the types the trace blames.

Common fixes: name intermediate types instead of inline conditional chains, prefer interface extends over large intersections, split wide barrel imports, and use project references so unchanged packages stay cached. Regenerate the trace after changes — the provider re-ingests automatically.

Documentation