use crate::query;
use crate::query::why::Why;
use super::{j_table, RowKind, J};
fn why_of(kind: &str) -> Why {
match kind {
"call" => Why::Call,
"jsx-use" => Why::JsxUse,
"dispatch" => Why::Dispatch,
_ => Why::Import,
}
}
pub(super) fn ts_table_fields<R>(
tables: &query::TsTables<R>,
row: impl Fn(&R, RowKind) -> J + Copy,
) -> Vec<(&'static str, J)> {
tables
.named()
.into_iter()
.filter(|(_, table)| table.total != 0)
.map(|(kind, table)| {
let why = why_of(kind);
(kind, j_table(table, move |r| row(r, RowKind::Ts(why))))
})
.collect()
}