Type Mappings
Every Rust type is automatically mapped to its TypeScript equivalent during code generation. Here's the complete reference.
| Rust | TypeScript | Notes |
|---|---|---|
String, &str, char | string | |
i8–i128, u8–u128, f32, f64 | number | or bigint via bigint_types |
bool | boolean | |
() | void | no-input procedures |
Vec<T>, HashSet<T>, BTreeSet<T> | T[] | also Array<T> in generic positions |
Option<T> | T | null | with serde(default): field?: T | null |
HashMap<K, V>, BTreeMap<K, V> | Record<K, V> | |
Box<T>, Arc<T>, Rc<T>, Cow<T> | T | transparent unwrap |
(A, B, C) | [A, B, C] | tuples |
[T; N] | T[] | fixed-size arrays |
Result<T, E> | T | Ok(T) unwrapped; Err(E) serialized as JSON and thrown as RpcError (status 500) |
struct | interface | |
enum (unit variants) | "A" | "B" | string union |
enum (data variants) | { A: T } | ... | see Serde Support for tagging |
Newtype struct Id(String) | type Id = string | or branded with branded_newtypes |
Try it
A single struct with every mapping from the table above. Click Fetch to see live values.