Merge pull request #921 from alexcrichton/fix-typescript

Fix TypeScript for generated constructors
This commit is contained in:
Alex Crichton 2018-10-03 09:09:23 -07:00 committed by GitHub
commit 05742177c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -713,10 +713,12 @@ impl<'a, 'b> Js2Rust<'a, 'b> {
.map(|s| format!("{}: {}", s.0, s.1))
.collect::<Vec<_>>()
.join(", ");
let ts = format!(
"{} {}({}): {};\n",
prefix, self.js_name, ts_args, self.ret_ty
);
let mut ts = 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");
(js, ts, self.js_doc_comments())
}
}