svenheden / csharp-models-to-typescript

C# models to TypeScript
89 stars 58 forks source link

Interfaces don't get converted #6

Closed jantimon closed 5 years ago

jantimon commented 5 years ago

Hey,

I just came to your project from https://stackoverflow.com/questions/54253927/convert-c-sharp-classes-and-interfaces-to-typescript and tried the following:

models/demo.cs

public interface IPhoneNumber {
    string Label { get; set; }
    string Number { get; set; }
    int MyProperty { get; set; }
}

public interface IPoint
{
   // Property signatures:
   int x
   {
      get;
      set;
   }

   int y
   {
      get;
      set;
   }
}

public class X {
    public IPhoneNumber test { get; set; }
    public IPoint test2 { get; set; }
}

Output:

declare module Api {
    // models/demo.cs
    export interface X {
        test: IPhoneNumber;
        test2: IPoint;
    }
}

As you can see IPoint and IPhoneNumber are not exported.

Is there any way to achieve that?

svenheden commented 5 years ago

@AdnanDervisevic fixed this in #9

Enjoy @jantimon!

jantimon commented 5 years ago

WOW That was quick! 👍

just tried and it works as expected:

declare module Api {
    // models/demo.cs
    export interface IPhoneNumber {
        Label: string;
        Number: string;
        MyProperty: number;
    }

    // models/demo.cs
    export interface IPoint {
        x: number;
        y: number;
    }

    // models/demo.cs
    export interface X {
        test: IPhoneNumber;
        test2: IPoint;
    }

}
svenheden commented 5 years ago

You're welcome