diff --git a/macros/src/types/generics.rs b/macros/src/types/generics.rs index 6f987dc..4766de9 100644 --- a/macros/src/types/generics.rs +++ b/macros/src/types/generics.rs @@ -91,6 +91,9 @@ pub fn format_type(ty: &Type, dependencies: &mut Dependencies, generics: &Generi dependencies.append(tuple_struct.dependencies); return tuple_struct.inline; } + Type::Reference(syn::TypeReference { ref elem, .. }) => { + return format_type(elem, dependencies, generics) + } _ => (), }; diff --git a/ts-rs/tests/references.rs b/ts-rs/tests/references.rs new file mode 100644 index 0000000..1aee02b --- /dev/null +++ b/ts-rs/tests/references.rs @@ -0,0 +1,15 @@ +use ts_rs::TS; + +#[test] +fn references() { + #[derive(TS)] + #[allow(dead_code)] + struct FullOfRefs<'a> { + str_slice: &'a str, + ref_slice: &'a [&'a str], + num_ref: &'a i32, + } + + assert_eq!(FullOfRefs::inline(), "{ str_slice: string, ref_slice: Array, num_ref: number, }") +} + diff --git a/ts-rs/tests/slices.rs b/ts-rs/tests/slices.rs index 14e0e9d..268a090 100644 --- a/ts-rs/tests/slices.rs +++ b/ts-rs/tests/slices.rs @@ -16,6 +16,17 @@ fn interface() { assert_eq!(Interface::inline(), "{ a: Array, }") } +#[test] +fn slice_ref() { + #[derive(TS)] + struct Interface<'a> { + #[allow(dead_code)] + a: &'a [&'a str] + } + + assert_eq!(Interface::inline(), "{ a: Array, }") +} + #[test] fn newtype() { #[derive(TS)]