Skip to main content

Module types

Module types 

Source
Expand description

TypeScript type generation and collection.

This module handles:

  • Collecting named types (structs and enums) from service definitions
  • Generating TypeScript type definitions (interfaces, type unions)
  • Converting Rust types to TypeScript type strings

Functions§

collect_named_types
Collect all named types (structs and enums with a name) from a service. Returns a vector of (name, Shape) pairs in dependency order.
generate_named_types
Generate TypeScript type definitions for all named types.
is_fully_supported
Check if a type can be fully encoded/decoded. Channel types (Tx/Rx) are supported - they encode as channel IDs.
ts_field_access
Generate TypeScript field access expression. Uses bracket notation for numeric field names (tuple fields), dot notation otherwise.
ts_scalar_type
Convert ScalarType to TypeScript type string.
ts_type
TypeScript type for user-facing type definitions. Uses named types when available.
ts_type_base_named
Convert Shape to TypeScript type string, using named types when available. This handles container types recursively, using named types at every level.
ts_type_client_arg
Convert Shape to TypeScript type string for client arguments. Schema is from server’s perspective - no inversion needed. Client passes the same types that server receives.
ts_type_client_return
Convert Shape to TypeScript type string for client returns. Schema is from server’s perspective - no inversion needed.
ts_type_server_arg
Convert Shape to TypeScript type string for server/handler arguments. Schema is from server’s perspective - no inversion needed. Rx means server receives, Tx means server sends.
ts_type_server_return
Schema is from server’s perspective - no inversion needed.