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

#936 breaks code generation for generic parent classes #994

Open
fwiesweg opened this issue Jun 14, 2023 · 0 comments
Open

#936 breaks code generation for generic parent classes #994

fwiesweg opened this issue Jun 14, 2023 · 0 comments

Comments

@fwiesweg
Copy link

fwiesweg commented Jun 14, 2023

First of all, thanks for all the good work, I think I already said it once but your library is and remains incredibly helpful!

#936 (commit d41d22f) seems to have broken code generation for classes with generic parents for me. I attached simplified samples of the issue below. The actual code is quite a bit more complicated, so in case you cannot reproduce it with these, please let me know so I can cook up something more complete.

Java:

@JsonSubTypes({
        @JsonSubTypes.Type(value = ClientPaymentSystem.class),
        @JsonSubTypes.Type(value = InternalPaymentSystem.class)
})
public abstract class PaymentSystem<CONF extends PaymentSystemConfig>{
}

public class InternalPaymentSystem extends PaymentSystem<VoidPaymentSystemConfig> {
   ...
}

Without #936:

export type PaymentSystemUnion<CONF> = ClientPaymentSystem | InternalPaymentSystem | ...
export interface PaymentSystem<CONF> extends CMDomainBaseModel, CMDomainEntitySubject {
    config: CONF;
    type: 'ClientPaymentSystem' | 'InternalPaymentSystem' | ....
}

export interface InternalPaymentSystem extends PaymentSystem<VoidPaymentSystemConfig> {
    active?: boolean | null;
    config: VoidPaymentSystemConfig;
    type: 'InternalPaymentSystem';
}

With #936:

export type PaymentSystemUnion<CONF> = ClientPaymentSystem | InternalPaymentSystem | ...
export interface PaymentSystem<CONF> extends CMDomainBaseModel, CMDomainEntitySubject {
    config: CONF;
    type: 'ClientPaymentSystem' | 'InternalPaymentSystem' | ....
}

// changed after extends
export interface InternalPaymentSystem extends PaymentSystemUnion<VoidPaymentSystemConfig> {
    active?: boolean | null;
    config: VoidPaymentSystemConfig;
    type: 'InternalPaymentSystem';
}

which does not compile with ts 4.7.4 (yes I know it's a bit dated...), claiming that inheritance is not possible because not all fields of the PaymentSystemUnion are known, contrary to those of PaymentSystem

I have read the commit message and code, but it's been a while since I've done a deep dive into your code and am not quite sure what the intention of this change is, so I'm hesitant to propose a half-baked fix in a pull request and would not mind some pointers if you have any.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant