Modules for inner classes

Issue #46 resolved
Nicholas Oxhøj
created an issue

Hi

I think inner classes need to be placed in modules which include the name of their parent/outer class. E.g. if I have classes like

namespace TypeLiteTest
{
    using TypeLite;

    [TsClass]
    public class Outer
    {
        public string Id { get; set; }

        [TsClass(Module = "TypeLiteTest.Outer")]
        public class Inner
        {
            public string Name { get; set; }
        }
    }
}

I will currently get TypeScript declarations like

declare module TypeLiteTest {
interface Outer {
  Id: string;
}
}
interface Inner {
  Name: string;
}
}

This way, if I have both an Outer1 and an Outer2, which both have en inner class Inner, then both of the TypeScript declarations will be placed in the TypeLiteTest module, creating a name clash.

Instead an inner class should probably be placed in a module which contains the class name of its parent/outer class, just as if the above example had been annotated like

[TsClass(Module = "TypeLiteTest.Outer")]
public class Inner

which would result in TypeScript declarations like

declare module TypeLiteTest {
interface Outer {
  Id: string;
}
}
declare module TypeLiteTest.Outer {
interface Inner {
  Name: string;
}
}

Comments (1)

  1. Log in to comment