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

Bug: Flattening generic type also flattens all generic parameters #233

Merged
merged 24 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
495a6bf
add test
NyxCode Feb 12, 2024
5daeed2
re-implement handeling of generics
NyxCode Feb 15, 2024
cab0908
Dependency::from_ty - remove generic params from name
NyxCode Feb 16, 2024
d764f5c
expand e2e test
NyxCode Feb 16, 2024
29248b4
adjust failing test
NyxCode Feb 16, 2024
4264c5f
fix optional features
NyxCode Feb 16, 2024
83b9541
fix TS_RS_EXPORT_DIR
NyxCode Feb 16, 2024
61c9692
add test for #70
NyxCode Feb 16, 2024
ebfa532
enable test for #214
NyxCode Feb 16, 2024
129b323
remove TODO about race condition - we fixed that with a mutex.
NyxCode Feb 16, 2024
0a68cef
remove TODO about #56 - already fixed
NyxCode Feb 16, 2024
2b5b9a9
remove "limitations" section from readme - both #56 and #70 are fixed
NyxCode Feb 16, 2024
5ab4aa9
Use type_params to simplify capture of Generics' identifiers
escritorio-gustavo Feb 16, 2024
3e31a3a
Add ident method
escritorio-gustavo Feb 16, 2024
bae3df8
Add dummy type to allow exporting types that use ToString as a generi…
escritorio-gustavo Feb 16, 2024
a693b60
use DerivedTS::ts_name instead of rust_ty
escritorio-gustavo Feb 16, 2024
bdb06d4
use TS::ident
escritorio-gustavo Feb 16, 2024
b4f6b01
Prefer renaming Enum to using all variants
escritorio-gustavo Feb 19, 2024
6d9a21f
Remove redundant clones
escritorio-gustavo Feb 19, 2024
3354dc7
Remove unused Option
escritorio-gustavo Feb 19, 2024
268742d
Fix inverted condition and separate the two checks
escritorio-gustavo Feb 19, 2024
3606c48
Merge branch 'main' into bug/flatten-generic-enum
escritorio-gustavo Feb 19, 2024
247276a
Remove redundant #[doc(hidden)]
escritorio-gustavo Feb 19, 2024
01615fe
Replace if Some else None with bool::then
escritorio-gustavo Feb 21, 2024
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/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ impl DerivedTS {
let test_fn = format_ident!("export_bindings_{}", rust_ty.to_string().to_lowercase());
let generic_params = generics
.type_params()
.map(|_| quote! { () });
.map(|_| quote! { ts_rs::Dummy });
escritorio-gustavo marked this conversation as resolved.
Show resolved Hide resolved
let ty = quote!(<#rust_ty<#(#generic_params),*> as ts_rs::TS>);

Some(quote! {
Expand Down
19 changes: 19 additions & 0 deletions ts-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -727,3 +727,22 @@ impl_primitives! {
}
#[rustfmt::skip]
pub(crate) use impl_primitives;


#[doc(hidden)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, Ord, PartialOrd)]
pub struct Dummy;

#[doc(hidden)]
escritorio-gustavo marked this conversation as resolved.
Show resolved Hide resolved
impl std::fmt::Display for Dummy {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self)
}
}

#[doc(hidden)]
impl TS for Dummy {
fn name() -> String { "Dummy".to_owned() }
fn transparent() -> bool { false }
}

1 change: 1 addition & 0 deletions ts-rs/tests/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use std::{
use ts_rs::TS;

#[derive(TS)]
#[ts(export)]
struct Generic<T>
where
T: TS,
Expand Down
Loading