Lab 09: Performance Types
Overview
Step 1: tsc --diagnostics Profiling
# Run type checker with performance metrics
tsc --noEmit --diagnostics
# Output:
# Files: 523
# Lines of Library: 57647
# Lines of Definitions: 42831
# Lines of TypeScript: 8234
# Lines of JavaScript: 0
# Lines of JSON: 125
# Nodes: 520931
# Identifiers: 189412
# Symbols: 148392
# Types: 108763
# Instantiations: 2847291 ← HIGH: slow types here
# Memory used: 256392K
# Assignability cache size: 27183
# Identity cache size: 5521
# Subtype cache size: 843
# I/O Read time: 0.03s
# Parse time: 1.42s
# ResolveModule time: 0.18s
# ResolveTypeReference time: 0.02s
# Bind time: 0.34s
# Check time: 8.74s ← Total type check time
# Emit time: 0.00s
# Total time: 10.75s
# Find the slowest files:
tsc --noEmit --extendedDiagnostics 2>&1 | grep "Check time" | sort -k3 -nStep 2: Slow Pattern — Large Union Discrimination
Step 3: Slow Pattern — Deep Recursive Conditional Types
Step 4: satisfies — Validate Without Widening
satisfies — Validate Without WideningStep 5: const Type Parameters (TypeScript 5.0)
const Type Parameters (TypeScript 5.0)Step 6: Variadic Tuple Types
Step 7: Type-Level Performance Checklist
Step 8: Capstone — FizzBuzz + Type Check Verification
Summary
Issue
Symptom
Fix
Last updated
