Merge pull request #1221 from rhysd/format-dts-file

Format .d.ts file
This commit is contained in:
Alex Crichton
2019-02-01 09:24:49 -06:00
committed by GitHub
2 changed files with 14 additions and 8 deletions

View File

@ -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())
}
}