diff --git a/macros/src/struct/named.rs b/macros/src/struct/named.rs index 3f2945d..1ea4030 100644 --- a/macros/src/struct/named.rs +++ b/macros/src/struct/named.rs @@ -72,12 +72,12 @@ fn format_field( if type_override.is_none() { dependencies.push(match inline { - true => quote!{ dependencies.append(&mut <#ty as ts_rs::TS>::dependencies()); }, - false => quote!{ + true => quote! { dependencies.append(&mut <#ty as ts_rs::TS>::dependencies()); }, + false => quote! { if <#ty as ts_rs::TS>::transparent() { dependencies.append(&mut <#ty as ts_rs::TS>::dependencies()); } else { - dependencies.push((std::any::TypeId::of::<#ty>(), <#ty as ts_rs::TS>::name())); + dependencies.push((std::any::TypeId::of::<#ty>(), <#ty as ts_rs::TS>::name())); } }, }); diff --git a/ts-rs/src/lib.rs b/ts-rs/src/lib.rs index b427fe0..4814313 100644 --- a/ts-rs/src/lib.rs +++ b/ts-rs/src/lib.rs @@ -124,7 +124,7 @@ pub trait TS: 'static { /// All type ids and typescript names of the types this type depends on. /// This is used for resolving imports when using the `export!` macro. fn dependencies() -> Vec<(TypeId, String)>; - + /// `true` if this is a transparent type, e.g tuples or a list. /// This is used for resolving imports when using the `export!` macro. fn transparent() -> bool;