mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-01 06:46:20 +03:00
Merge pull request #236 from spastorino/remove-wrong-types-conversion
Remove wrong types conversion from typescript crate
This commit is contained in:
commit
71107b8e80
@ -12,5 +12,5 @@ fn main() {
|
||||
|
||||
let mut tokens = TokenStream::new();
|
||||
program.to_tokens(&mut tokens);
|
||||
println!("{}", tokens);
|
||||
println!("{:#?}", tokens);
|
||||
}
|
||||
|
@ -67,11 +67,9 @@ fn parse_json(file_name: &str) -> TsPackage {
|
||||
|
||||
fn build_function(name: String, parameters: HashMap<String, TsMethodProperty>, return_value: TsReturnValue) -> Function {
|
||||
let arguments = parameters.iter().map( |(_name, property)| {
|
||||
let property_type = rust_type(&property.property_type);
|
||||
|
||||
let mut segments = syn::punctuated::Punctuated::new();
|
||||
segments.push(syn::PathSegment {
|
||||
ident: syn::Ident::new(property_type, proc_macro2::Span::call_site()),
|
||||
ident: syn::Ident::new(&property.property_type, proc_macro2::Span::call_site()),
|
||||
arguments: syn::PathArguments::None,
|
||||
});
|
||||
|
||||
@ -84,11 +82,9 @@ fn build_function(name: String, parameters: HashMap<String, TsMethodProperty>, r
|
||||
})
|
||||
}).collect::<Vec<_>>();
|
||||
|
||||
let ret_property_type = rust_type(&return_value.property_type);
|
||||
|
||||
let mut ret_segments = syn::punctuated::Punctuated::new();
|
||||
ret_segments.push(syn::PathSegment {
|
||||
ident: syn::Ident::new(ret_property_type, proc_macro2::Span::call_site()),
|
||||
ident: syn::Ident::new(&return_value.property_type, proc_macro2::Span::call_site()),
|
||||
arguments: syn::PathArguments::None,
|
||||
});
|
||||
|
||||
@ -122,17 +118,3 @@ fn build_function(name: String, parameters: HashMap<String, TsMethodProperty>, r
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: implement this properly
|
||||
fn rust_type(js_type: &str) -> &'static str {
|
||||
match js_type {
|
||||
"string" => "String",
|
||||
"number" => "String",
|
||||
"boolean" => "bool",
|
||||
"symbol" => "String",
|
||||
"object" => "String",
|
||||
"function" => "String",
|
||||
"void" => "String",
|
||||
_ => "String",
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user