pub fn type_object(fields: Vec<String>) -> String {
if fields.is_empty() {
"{}".to_string()
} else {
let mut out = String::new();
out.push_str("{\n");
for field in fields {
let indented = indent_lines(&field, " ");
out.push_str(&indented);
out.push_str(";\n");
}
out.push('}');
out
}
}
pub fn ts_quote(value: &str) -> String {
let escaped = value.replace('\\', "\\\\").replace('"', "\\\"");
format!("\"{escaped}\"")
}
pub fn indent_inline(value: &str, prefix: &str) -> String {
value.replace('\n', &format!("\n{prefix}"))
}
fn indent_lines(value: &str, prefix: &str) -> String {
value
.lines()
.map(|line| format!("{prefix}{line}"))
.collect::<Vec<_>>()
.join("\n")
}