From ef56d7a89ba11a786fc8ca5dd80e72e6a0e012c6 Mon Sep 17 00:00:00 2001 From: Gustavo Date: Mon, 29 Jan 2024 17:59:34 -0300 Subject: [PATCH] Use inline instead of name, Vec was turning into Array --- macros/src/types/generics.rs | 2 +- ts-rs/tests/generics.rs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/macros/src/types/generics.rs b/macros/src/types/generics.rs index beacc2959..5bf26ffd6 100644 --- a/macros/src/types/generics.rs +++ b/macros/src/types/generics.rs @@ -64,7 +64,7 @@ pub fn format_type(ty: &Type, dependencies: &mut Dependencies, generics: &Generi } return quote!( - match <#generic_ident>::name().as_str() { + match <#generic_ident>::inline().as_str() { // When exporting a generic, the default type used is `()`, // which gives "null" when calling `.name()`. In this case, we // want to preserve the type param's identifier as the name used diff --git a/ts-rs/tests/generics.rs b/ts-rs/tests/generics.rs index 961fffc0b..703868e47 100644 --- a/ts-rs/tests/generics.rs +++ b/ts-rs/tests/generics.rs @@ -147,6 +147,7 @@ fn generic_struct() { } #[test] +// https://github.com/Aleph-Alpha/ts-rs/issues/56 TODO fn inline() { #[derive(TS)] struct Generic { @@ -159,13 +160,13 @@ fn inline() { #[ts(inline)] gi: Generic, #[ts(flatten)] - t: Generic, + t: Generic>, } assert_eq!(Generic::<()>::decl(), "type Generic = { t: T, }"); assert_eq!( Container::decl(), - "type Container = { g: Generic, gi: { t: string, }, t: string, }" + "type Container = { g: Generic, gi: { t: string, }, t: Array, }" ); }