C# classes are being converted as interfaces

Issue #69 invalid
Former user created an issue

If I take a c# class:

public class Foo(){ int FooId { get; set; } }

And use typelite to convert this into a typescript file, the generated output is:

interface Foo(){ FooId: number; }

This seems to be incorrect, since it should generate

class Foo(){ FooId: number; }

While Interface Foo() should be generated by the code:

interface Foo(){ int FooId { get; set; } }

Comments (4)

  1. Lukas Kabrt

    This is intended behaviour. The primary purpose of the TypeLITE library is to maintain type consistency across .NET and TypeScript boundary. So you have a C# class, TypeLITE generates an interface of the class and you provide your own implementation of the interface in the TypeScript. Keep in mind, that in TypeScript you can instantiate an interface directly.

    If you want to generate classes and not interfaces, it will be better to take similar approach as in this pull request - https://bitbucket.org/LukasKabrt/typelite/pull-request/20/68-allow-support-for-additional-generators

  2. Log in to comment