Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in #212 #215

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion macros/src/types/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions ts-rs/tests/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ fn generic_struct() {
}

#[test]
// https://github.com/Aleph-Alpha/ts-rs/issues/56 TODO
fn inline() {
#[derive(TS)]
struct Generic<T> {
Expand All @@ -159,13 +160,13 @@ fn inline() {
#[ts(inline)]
gi: Generic<String>,
#[ts(flatten)]
t: Generic<String>,
t: Generic<Vec<String>>,
}

assert_eq!(Generic::<()>::decl(), "type Generic<T> = { t: T, }");
assert_eq!(
Container::decl(),
"type Container = { g: Generic<string>, gi: { t: string, }, t: string, }"
"type Container = { g: Generic<string>, gi: { t: string, }, t: Array<string>, }"
);
}

Expand Down
Loading