170 releases (110 breaking)
Uses new Rust 2024
| new 0.110.0 | Jan 19, 2026 |
|---|---|
| 0.108.0 | Jan 12, 2026 |
| 0.106.0 | Dec 29, 2025 |
| 0.99.0 | Nov 24, 2025 |
| 0.0.1 | Mar 30, 2023 |
#1178 in Programming languages
42,874 downloads per month
Used in 156 crates
(22 directly)
4MB
74K
SLoC
Oxc Semantic
Comprehensive semantic analysis for JavaScript and TypeScript programs.
Overview
This crate performs semantic analysis on JavaScript and TypeScript ASTs, building symbol tables, scope trees, and control flow graphs. It provides the foundation for advanced static analysis, linting, and transformation tools.
Key Features
- Symbol resolution: Build complete symbol tables with binding information
- Scope analysis: Construct scope trees following ECMAScript scoping rules
- Reference tracking: Track all variable references and their relationships
- Control flow: Optional control flow graph construction
- JSDoc parsing: Extract and parse JSDoc comments
- Module analysis: Analyze import/export relationships
Architecture
Semantic Analysis Pipeline
- AST Traversal: Visit all nodes to collect declarations
- Scope Building: Construct scope tree following language rules
- Symbol Resolution: Create symbol table with binding information
- Reference Analysis: Track all identifier references
- Control Flow: Optionally build control flow graphs
- JSDoc Processing: Parse and attach documentation
Key Data Structures
Symbol Table
- Symbols: All declared identifiers (variables, functions, classes, etc.)
- References: All uses of identifiers
- Bindings: Association between names and symbols in scopes
Scope Tree
- Scope hierarchy: Nested scopes following language semantics
- Binding resolution: How identifiers resolve to declarations
- Closure analysis: Capture and usage patterns
Control Flow Graph
- Basic blocks: Sequences of statements with single entry/exit
- Flow edges: Conditional and unconditional control flow
- Exception handling: Try/catch/finally flow modeling
Applications
- Linting: Detect unused variables, undefined references, etc.
- Transformation: Safe variable renaming and scope analysis
- Analysis: Dead code detection, dependency analysis
- IDE features: Go-to-definition, find references, refactoring
The semantic analyzer provides the deep program understanding needed for sophisticated JavaScript and TypeScript tooling.
Dependencies
~7MB
~121K SLoC