reinforced / Reinforced.Typings

Converts C# classes to TypeScript interfaces (and many more) within project build. 0-dependency, minimal, gluten-free
MIT License
507 stars 82 forks source link

Issue when base class is exported as interface #263

Open nvirth opened 1 year ago

nvirth commented 1 year ago

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 commented 1 year ago

Nice catch! Will try to create unit test