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

Issue when base class is exported as interface #263

Open
nvirth opened this issue Jul 6, 2023 · 1 comment
Open

Issue when base class is exported as interface #263

nvirth opened this issue Jul 6, 2023 · 1 comment

Comments

@nvirth
Copy link

nvirth commented Jul 6, 2023

The following C# code:

[TsClass(AutoExportProperties = true)]
public class MyBase
{
    public bool BaseProperty1 { get; set; };
    public bool BaseProperty2 { get; set; };
}


[TsInterface(FlattenHierarchy = true, AutoExportProperties = true)]
public class MyDescendant : MyBase
{
    public bool DescendantProperty1 { get; set; };
    public bool DescendantProperty2 { get; set; };
}

Will have the following TypeScript code generated:

interface MyBase
{
    BaseProperty1: boolean;
    BaseProperty2: boolean;
}


/**
* @todo Automatically implemented from MyBase
*/
class MyDescendant
{
    BaseProperty1: boolean; // [X] Base properties are duplicated
    BaseProperty1: boolean;
    BaseProperty2: boolean;
    BaseProperty2: boolean;
    DescendantProperty1: boolean;
    DescendantProperty2: boolean;
}

So there is a descendant C# class (TS class), and its base C# class (TS interface), and the base's properties get duplicated while code generation.

In case MyBase is Substituted instead of annotated with [TsClass], the above one works perfectly.

@pavel-b-novikov
Copy link
Member

Nice catch! Will try to create unit test

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

2 participants