typescript-language-server-0.1.0 is not a library.
TypeScript Language Server (Rust)
A high-performance Language Server Protocol (LSP) implementation for TypeScript and JavaScript, written in Rust.
Features
Language Support
- TypeScript (
.ts) - TypeScript React (
.tsx) - JavaScript (
.js,.mjs,.cjs) - JavaScript React (
.jsx)
LSP Capabilities
| Feature | Status | Description |
|---|---|---|
| Document Symbols | ✅ | Outline view with functions, classes, variables |
| Semantic Tokens | ✅ | Rich syntax highlighting |
| Diagnostics | ✅ | Syntax errors and type diagnostics |
| Hover | ✅ | Type information and JSDoc comments |
| Folding Ranges | ✅ | Collapse functions, classes, imports |
| Selection Range | ✅ | Smart expand/shrink selection |
| Go to Definition | ✅ | Navigate to symbol definitions |
| Find References | ✅ | Find all usages of a symbol |
| Rename Symbol | ✅ | Rename across scope |
| Completions | ✅ | IntelliSense with built-ins and scope |
| Signature Help | ✅ | Function parameter hints |
| Inlay Hints | ✅ | Type and parameter annotations |
| Code Actions | ✅ | Quick fixes and refactorings |
Installation
From Source
# Clone the repository
# Build the language server
# The binary will be at target/release/typescript-language-server
VSCode Extension
Then press F5 in VSCode to launch the extension development host.
Usage
Command Line
# Start the language server (communicates via stdio)
With VSCode
- Open the
editors/vscodefolder in VSCode - Run
pnpm installto install dependencies - Press
F5to launch the Extension Development Host - Open any TypeScript or JavaScript file
With Other Editors
The language server uses standard LSP over stdio. Configure your editor's LSP client to run:
Architecture
┌─────────────────────────────────────────────────────────┐
│ LSP Server (tower-lsp) │
└─────────────────────────────┬───────────────────────────┘
│
┌─────────────────────────────▼───────────────────────────┐
│ Project System │
│ (tsconfig, file graph, workspace) │
└─────────────────────────────┬───────────────────────────┘
│
┌─────────────────────────────▼───────────────────────────┐
│ Type Checker │
│ (inference, narrowing, assignability) │
└─────────────────────────────┬───────────────────────────┘
│
┌─────────────────────────────▼───────────────────────────┐
│ Binder / Symbol Table │
│ (scopes, symbols, references) │
└─────────────────────────────┬───────────────────────────┘
│
┌─────────────────────────────▼───────────────────────────┐
│ Module Resolver │
│ (imports, node_modules, path mapping) │
└─────────────────────────────┬───────────────────────────┘
│
┌─────────────────────────────▼───────────────────────────┐
│ Parser (tree-sitter) │
│ (AST, syntax tree) │
└─────────────────────────────────────────────────────────┘
Project Structure
typescript-language-server/
├── src/
│ ├── main.rs # Entry point
│ ├── server.rs # LSP server implementation
│ ├── document.rs # Document management
│ ├── parser.rs # tree-sitter parsing
│ ├── analysis/ # Symbol table & binder
│ │ ├── scope.rs # Scope tree
│ │ ├── symbol.rs # Symbol definitions
│ │ ├── symbol_table.rs # Per-file symbol storage
│ │ └── binder.rs # AST → symbols
│ ├── capabilities/ # LSP features
│ │ ├── completions.rs
│ │ ├── diagnostics.rs
│ │ ├── hover.rs
│ │ ├── definition.rs
│ │ └── ...
│ ├── resolution/ # Module resolution
│ │ ├── resolver.rs
│ │ ├── tsconfig.rs
│ │ └── node_modules.rs
│ ├── project/ # Project system
│ │ ├── project.rs
│ │ ├── file_graph.rs
│ │ └── workspace.rs
│ └── types/ # Type system
│ ├── types.rs # Type representations
│ ├── checker.rs # Type checker
│ └── printer.rs # Type display
├── editors/
│ └── vscode/ # VSCode extension
├── benches/ # Criterion benchmarks
└── benchmarks/ # LSP comparison benchmarks
Development
Prerequisites
- Rust 1.70+
- Node.js 18+
- pnpm (for VSCode extension)
Building
# Debug build
# Release build
# Run tests
# Run with logging
RUST_LOG=debug
Testing
# Run all Rust tests
# Run tests with output
# Run specific test
# Run VSCode extension tests
Code Coverage
# Install cargo-llvm-cov
# Generate coverage report
# View report
Benchmarks
# Run Rust benchmarks
# Run LSP comparison benchmarks
Configuration
The language server respects tsconfig.json / jsconfig.json files:
Supported Options
compilerOptions.targetcompilerOptions.modulecompilerOptions.moduleResolution(node, node16, nodenext, bundler)compilerOptions.baseUrlcompilerOptions.pathscompilerOptions.strictand related flagsinclude/excludepatternsextendsfor configuration inheritance
Performance
This implementation uses:
- tree-sitter for fast, incremental parsing
- DashMap for concurrent document storage
- tower-lsp for async LSP handling
Benchmarks show significant improvements over the official TypeScript language server for parsing and symbol resolution operations.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Development Guidelines
- Run
cargo fmtbefore committing - Ensure
cargo clippypasses - Add tests for new features
- Update documentation as needed
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- tower-lsp - LSP server framework
- tree-sitter - Incremental parsing
- tree-sitter-typescript - TypeScript grammar
- TypeScript - Language specification reference