reluxscript 0.1.4

Write AST transformations once. Compile to Babel, SWC, and beyond.
Documentation
// Generated by ReluxScript compiler
// Do not edit manually
// NOTE: SWC plugins require nightly Rust

use swc_common::{Span, DUMMY_SP, SyntaxContext};
use swc_ecma_ast::*;
use swc_ecma_visit::{Visit, VisitMut, VisitMutWith, VisitWith};

#[derive(Clone, Debug)]
struct Foo {
    name: String,
}

impl Foo {
    fn new(name: String) -> Foo {
        Foo { name: name }
    }
    
    fn get_name(&mut self) -> String {
        self.name.to_string()
    }
    
}

#[derive(Clone, Debug)]
struct State {
    output: String,
    count: i32,
}

pub struct NeedsToString {
    pub state: State,
}

impl VisitMut for NeedsToString {
    fn visit_mut_fn_decl(&mut self, node: &mut FnDecl) {
        match &node.function.return_type {
            Option::Some(type_ann) => {
                {
                    match &*type_ann.type_ann.as_ref() {
                        TsType::TsKeywordType(TsKeywordType { kind: TsKeywordTypeKind::TsStringKeyword, .. }) => {
                            {
                                self.state.output = "string".to_string()
                            }
                        }
                        _ => {
                            {
                            }
                        }
                    }
                }
            }
            Option::None => {
                {
                }
            }
        }
    }
    
}

impl NeedsToString {
    pub fn new() -> Self {
        Self {
            state: State {
                output: Default::default(),
                count: 0,
            },
        }
    }
    
    fn init() -> State {
        State { output: "".to_string(), count: 0 }
    }
    
}