Expand description
§typespec-rs
A Rust implementation of the TypeSpec type system — parser, type checker, and emitter.
This is an independent Rust port of the TypeSpec compiler, not a binding to the TypeScript compiler. It implements the parser, checker, and emitter pipeline natively in Rust.
§Quick Start
ⓘ
use typespec_rs::emit::{to_yaml, to_json};
let src = r#"
model Pet {
id: string;
name: string;
age?: int32;
}
"#;
let yaml = to_yaml(src).unwrap();
let json = to_json(src).unwrap();§Module Organization
emit— Convert TypeSpec to YAML/JSON output (primary user-facing API)parser— Parse TypeSpec source into ASTchecker— Type checking and semantic analysisast— AST node types
Internal modules (#[doc(hidden)]) are used by the compiler pipeline
but are not part of the stable public API.
§Status
This project is in early development. The scanner, parser, and core type checker are functional. See the repository for the latest status.
Modules§
- ast
- Abstract Syntax Tree types for TypeSpec.
- checker
- TypeSpec Checker - Core type checking for TypeSpec-Rust Ported from TypeSpec compiler/src/core/checker.ts
- code_
fixes - Code fix utilities for TypeSpec-Rust
- diagnostics
- Diagnostics module for TypeSpec-Rust
- emit
- TypeSpec Emit API
- libs
- TypeSpec Library Modules
- mime_
type - MIME type utilities for TypeSpec-Rust
- param_
message - Param message utilities for TypeSpec-Rust
- parser
- TypeSpec Parser implementation
- path_
utils - Path utilities for TypeSpec-Rust
- perf
- Performance timing utilities for TypeSpec-Rust
- source_
file - Source file utilities for TypeSpec-Rust
- utils
- Utility data structures and functions
Macros§
- flag_
decorator - Generate a flag decorator (apply + is pair).
- numeric_
decorator - Generate a numeric decorator (apply + get pair).
- optional_
name_ decorator - Generate an optional-name decorator (apply + is + get_name triple).
- string_
decorator - Generate a string decorator (apply + get pair).
- string_
enum - Generate an enum with
as_str()andparse_str()methods. - typeid_
decorator - Generate a TypeId decorator (apply + get pair).
- visibility_
decorator - Generate a visibility decorator (apply + get pair for comma-separated modifiers).