use crate::FastStr;
impl ts_rs::TS for FastStr {
type OptionInnerType = Self;
type WithoutGenerics = Self;
fn name() -> String {
"string".to_owned()
}
fn inline() -> String {
<Self as ts_rs::TS>::name()
}
fn inline_flattened() -> String {
panic!("{} cannot be flattened", <Self as ts_rs::TS>::name())
}
fn decl() -> String {
panic!("{} cannot be declared", <Self as ts_rs::TS>::name())
}
fn decl_concrete() -> String {
panic!("{} cannot be declared", <Self as ts_rs::TS>::name())
}
}
#[test]
fn test_ts_rs() {
#[derive(ts_rs::TS)]
struct Nested {
#[allow(unused)]
#[ts(rename = "nested_id")]
id: FastStr,
}
#[derive(ts_rs::TS)]
struct Test {
#[allow(unused)]
#[ts(optional)]
id: Option<FastStr>,
#[allow(unused)]
#[ts(flatten)]
nested: Nested,
}
assert_eq!(
<Test as ts_rs::TS>::decl(),
"type Test = { id?: string, nested_id: string, };"
);
}