typeshare icon indicating copy to clipboard operation
typeshare copied to clipboard

Generics exist in generated code even if they are unused

Open snowsignal opened this issue 1 year ago • 1 comments

If a type doesn't serialize any generic fields, we shouldn't be applying a generic parameter to the generated code. However, this is currently not the case.

Ideally, these definitions should not generate data classes/type aliases with generics.

#[typeshare]
struct Phantom<A> {
  some_value: u32,
  _phantom_data: PhantomData<A>
}
#[typeshare]
struct UnusedGeneric<A, B, C> {}

snowsignal avatar Apr 09 '23 07:04 snowsignal

Is there a possibility that the destination type should have these generics? I'm thinking about a hypothetical case like Uuid<Account> vs Uuid<Collection>, where those types would want to have equivalent distinct generics on the output side.

Lucretiel avatar Jul 13 '23 16:07 Lucretiel