tsz
A high-performance TypeScript compiler and checker written in Rust, designed to be compatible with standard TypeScript while offering significantly faster build times and specialized checking modes.
tsz is an experimental, TypeScript-compatible compiler, checker, and language service built from the ground up in Rust. The project is focused on achieving high performance and compatibility with the standard TypeScript compiler (tsc). While it is currently under active development and not yet a drop-in replacement for tsc, tsz aims to mirror its diagnostics, inference logic, and emitted output, providing a faster alternative for developers while working toward full conformance with the official TypeScript test suite.
Some of the key features are:
- High Performance: Built in Rust to leverage efficient memory management and concurrency, offering faster compilation times compared to conventional TypeScript compilers.
- Optimized Architecture: Utilizes arena-based memory allocation and interned handles for types and strings, ensuring efficient use of CPU cache and low overhead for large codebases.
- TypeScript Compatibility: Tracks conformance against the official TypeScript compiler, ensuring that type checking, JavaScript emission, and editor behavior align with user expectations.
- Language Service: Implements a Language Server Protocol (LSP) to provide IDE features such as code completion, hover information, and diagnostic reporting.
- Sound Mode: An experimental setting designed to explore stricter static checking and address common TypeScript edge cases that allow potentially unsafe patterns.
- Standardized Pipeline: Follows a structured compiler pipeline consisting of a Scanner, Parser, Binder, Checker, Solver, and Emitter to ensure clean separation of concerns.
The compiler works by transforming source text into a compact Abstract Syntax Tree (AST) stored in an arena. The Binder establishes symbol tables and control-flow graphs, while the Checker orchestrates semantic validation by querying the Solver. The Solver handles type relations, subtyping, and inference, utilizing memoization and coinductive semantics to manage complex type interactions efficiently. This modular approach allows for targeted improvements to performance and compatibility while maintaining a stable foundation for type analysis.
Some common use cases include:
- Accelerating Build Pipelines: Integrating tsz as a drop-in or auxiliary checker to improve compilation speed for large TypeScript projects during development.
- IDE Tooling: Utilizing the tsz language service to provide high-performance code intelligence and diagnostics within code editors.
- Type Checking Experiments: Using the Sound Mode feature to experiment with stricter type rules to identify potential bugs or unsafe patterns in TypeScript codebases.
- Benchmarking Compiler Performance: Serving as a reference implementation for optimizing TypeScript compilation workloads and understanding the architectural tradeoffs in language compilers.
Comments
0Markdown is supported.