mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-16 10:10:52 +00:00
commit
2e80313aa3
@ -750,12 +750,16 @@ impl<'a, 'b> Js2Rust<'a, 'b> {
|
||||
.map(|s| format!("{}: {}", s.0, s.1))
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ");
|
||||
let mut ts = format!("{} {}({})", prefix, self.js_name, ts_args);
|
||||
let mut ts = if prefix.is_empty() {
|
||||
format!("{}({})", self.js_name, ts_args)
|
||||
} else {
|
||||
format!("{} {}({})", prefix, self.js_name, ts_args)
|
||||
};
|
||||
if self.constructor.is_none() {
|
||||
ts.push_str(": ");
|
||||
ts.push_str(&self.ret_ty);
|
||||
}
|
||||
ts.push_str(";\n");
|
||||
ts.push(';');
|
||||
(js, ts, self.js_doc_comments())
|
||||
}
|
||||
}
|
||||
|
@ -845,7 +845,7 @@ impl<'a> Context<'a> {
|
||||
",
|
||||
name,
|
||||
));
|
||||
ts_dst.push_str("free(): void;\n");
|
||||
ts_dst.push_str(" free(): void;");
|
||||
dst.push_str(&class.contents);
|
||||
ts_dst.push_str(&class.typescript);
|
||||
dst.push_str("}\n");
|
||||
@ -2399,6 +2399,8 @@ impl<'a, 'b> SubContext<'a, 'b> {
|
||||
.contents
|
||||
.push_str(&format_doc_comments(&export.comments, Some(js_doc)));
|
||||
|
||||
class.typescript.push_str(" "); // Indentation
|
||||
|
||||
if export.is_constructor {
|
||||
if class.has_constructor {
|
||||
bail!("found duplicate constructor `{}`", export.function.name);
|
||||
@ -2571,12 +2573,12 @@ impl<'a, 'b> SubContext<'a, 'b> {
|
||||
.typescript
|
||||
.push_str(&format!("export enum {} {{", enum_.name));
|
||||
|
||||
variants.clear();
|
||||
for variant in enum_.variants.iter() {
|
||||
variants.push_str(&format!("{},", variant.name));
|
||||
self.cx
|
||||
.typescript
|
||||
.push_str(&format!("\n {},", variant.name));
|
||||
}
|
||||
self.cx.typescript.push_str(&variants);
|
||||
self.cx.typescript.push_str("}\n");
|
||||
self.cx.typescript.push_str("\n}\n");
|
||||
}
|
||||
|
||||
fn generate_struct(&mut self, struct_: &decode::Struct) -> Result<(), Error> {
|
||||
@ -2596,7 +2598,7 @@ impl<'a, 'b> SubContext<'a, 'b> {
|
||||
.argument(&descriptor)?
|
||||
.ret(&Descriptor::Unit)?;
|
||||
ts_dst.push_str(&format!(
|
||||
"{}{}: {};\n",
|
||||
"\n {}{}: {};",
|
||||
if field.readonly { "readonly " } else { "" },
|
||||
field.name,
|
||||
&cx.js_arguments[0].1
|
||||
|
Loading…
x
Reference in New Issue
Block a user