pub struct TypeScriptBackend { /* private fields */ }Expand description
The TypeScript code generation backend.
Compiles OxiLean LCNF declarations into TypeScript source code.
Implementations§
Source§impl TypeScriptBackend
impl TypeScriptBackend
Sourcepub fn add_declaration(&mut self, decl: TsDeclaration)
pub fn add_declaration(&mut self, decl: TsDeclaration)
Add a declaration to the module.
Sourcepub fn add_import(&mut self, imp: TsImport)
pub fn add_import(&mut self, imp: TsImport)
Add an import to the module.
Sourcepub fn make_discriminated_union(
&self,
type_name: &str,
variants: &[(&str, Vec<(&str, TsType)>)],
) -> TsTypeAlias
pub fn make_discriminated_union( &self, type_name: &str, variants: &[(&str, Vec<(&str, TsType)>)], ) -> TsTypeAlias
Build a discriminated union type from a list of variant names and their fields.
Example:
type Shape =
| { kind: 'circle'; radius: number }
| { kind: 'rect'; w: number; h: number }Sourcepub fn emit_module(&self) -> String
pub fn emit_module(&self) -> String
Emit the full TypeScript module source.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TypeScriptBackend
impl RefUnwindSafe for TypeScriptBackend
impl Send for TypeScriptBackend
impl Sync for TypeScriptBackend
impl Unpin for TypeScriptBackend
impl UnsafeUnpin for TypeScriptBackend
impl UnwindSafe for TypeScriptBackend
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more