How to change the module name?

Issue #9 resolved
Former user created an issue

I see examples for changing the class name and member name, but nor for the module itself. Can this be done?

Comments (7)

  1. Lukas Kabrt repo owner

    You can change name of the module for a class with the TsClassAttribute and it's Module property.

    If it is left empty, the namespace of the class is used as the module name, otherwise the generated TS class definition is placed into a module with the specified name.

  2. Kevin Bennett

    So I would have to add attributes to my .net classes? It would be nice to not pollute my POCOs with attributes. What about an overload of the For<T>() call that accepts a namespace?

  3. daniel_harvey

    +1 for TypeScriptFluent extension

    Perhaps a few reflection-based extensions?

    .WithNamespace("foo")
    .ForLoadedMatching("*Commands", "*Result")
    .ForNamespace("Foo.Services", /* optional */ "*Commands", "*Result")
    
  4. Lukas Kabrt repo owner

    The fluent configuration for module name and class name is implemented and will be released in the next version.

    Example:

    TypeScript.Definitions()
        .For<TypeLite.Demo.Models.Order>()
            .Named("LiteSolutionsOrder")
            .ToModule("Litesolutions.Eshop")
    
  5. E G

    This changes only module names for Order class but all the dependent classes still have default names. this is not expected I would say. How to change module name for all transformed classes

  6. Log in to comment