Oak TypeScript Parser
High-performance incremental TypeScript parser for the oak ecosystem with flexible configuration, optimized for modern JavaScript development.
🎯 Overview
Oak TypeScript is a robust parser for TypeScript, designed to handle complete TypeScript syntax including modern features. Built on the solid foundation of oak-core, it provides both high-level convenience and detailed AST generation for TypeScript analysis and tooling.
✨ Features
- Complete TypeScript Syntax: Supports all TypeScript features including modern specifications
- Full AST Generation: Generates comprehensive Abstract Syntax Trees
- Lexer Support: Built-in tokenization with proper span information
- Error Recovery: Graceful handling of syntax errors with detailed diagnostics
🚀 Quick Start
Basic example:
use ;
📋 Parsing Examples
Interface Parsing
use ;
let parser = new;
let source = new;
let result = parser.parse;
println!;
Function Parsing
use ;
let parser = new;
let source = new;
let result = parser.parse;
println!;
Class Parsing
use ;
let parser = new;
let source = new;
let result = parser.parse;
println!;
🔧 Advanced Features
Token-Level Parsing
use ;
let parser = new;
let source = new;
let result = parser.parse;
// Token information is available in the parse result
Error Handling
use ;
let parser = new;
let source = new;
let result = parser.parse;
if let Err = result.result
🏗️ AST Structure
The parser generates a comprehensive AST with the following main structures:
- SourceFile: Root container for TypeScript source files
- InterfaceDeclaration: TypeScript interface definitions
- ClassDeclaration: TypeScript class definitions
- FunctionDeclaration: Function and method definitions
- VariableStatement: Variable declarations
- Expression: Various expression types
- TypeAnnotation: Type annotations and type references
📊 Performance
- Streaming: Parse large TypeScript files without loading entirely into memory
- Incremental: Re-parse only changed sections
- Memory Efficient: Smart AST node allocation
- Fast Recovery: Quick error recovery for better IDE integration
🔗 Integration
Oak of typescript integrates seamlessly with:
- Web Development: Build TypeScript development tools and analyzers
- IDE Support: Language server protocol compatibility for TypeScript
- Build Tools: Integrate with bundlers and build pipelines
- Code Analysis: Analyze and understand TypeScript codebases
- Documentation Tools: Extract documentation from TypeScript source code
📚 Examples
Check out the examples directory for comprehensive examples:
- Complete TypeScript source file parsing
- Interface and class analysis
- Type extraction and validation
- Integration with development workflows
🤝 Contributing
Contributions are welcome!
Please feel free to submit pull requests at the project repository or open issues.