Company
Date Published
Author
Scott Trinh
Word count
8575
Language
English
Hacker News points
2

Summary

The TypeScript type checker's workload can be difficult to optimize, leading to sluggish IDE responsiveness or compiler crashes. To address this, developers can use various tools and techniques, such as measuring type instantiations using `--extendedDiagnostics` or `--generateTrace`, and benchmarking changes with tools like `@arktype/attest`. The "BAM" method involves creating a new branch for each experiment, adjusting the code based on a hypothesis, and then benchmarking the changes to measure their impact. Additionally, some general advice can be provided, such as preferring interfaces over intersections, naming conditional types, moving expensive generic expressions into generics, and rearranging conditionals to make the most expensive or common cases cheaper. The development of new performance tools, such as measuring language server wall time, tracing language server performance, providing performance-specific guidance through linters, and refactoring tools at the type level, would further improve the process of improving type inference performance.