Expand description
TypeScript code generation macros for macroforge.
This crate provides procedural macros for generating TypeScript code from Rust. It offers two primary approaches:
-
ts_quote!- A thin wrapper around SWC’squote!macro with enhanced interpolation syntax for compile-time validated TypeScript generation. -
ts_template!- A Rust-style template syntax with control flow ({#if},{#for},{#match}) and expression interpolation (@{expr}).
§Architecture
The quote implementation uses TypeScript parsing (Syntax::Typescript) instead
of JavaScript, enabling native support for type annotations and TypeScript syntax.
§Insert Positions
ts_template! supports an optional position keyword to control where generated
code is inserted:
ⓘ
// Insert inside the class body
ts_template!(Within { ... })
// Insert at the top of the file (for imports)
ts_template!(Top { ... })
// Default: insert after the target (Below)
ts_template! { ... }Available positions: Top, Above, Within, Below, Bottom
Macros§
- ts_
quote - Parse and generate code for a TypeScript quote.
- ts_
template - Generate TypeScript code with Rust-style control flow and interpolation.