reinforced/Reinforced.Typings

Issue when base class is exported as interface

nvirth opened this issue · 1 comments

nvirth commented

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.

Nice catch! Will try to create unit test