Now there is a command TypeScriptFluent.WithFormatterthat accepts a delegate TsModuleNameFormatterso that you can translate module names. For example, this code converts the module name to the last part of your namespace ( MyCompany.Business.Module1→ Module1):
<#
var ts = TypeScript.Definitions()
.WithFormatter((TsModuleNameFormatter)FormatModuleName)
#>
<#+
string FormatModuleName(string module) {
var parts = module.Split(new []{'.'});
var newModule = parts[parts.Length - 1];
return newModule;
}
#>
Update:
In the latest version of TypeLite 1.1.2.0, the API has changed a bit, so the previous example would look like this:
<#
var ts = TypeScript.Definitions().WithModuleNameFormatter((TsModuleNameFormatter)FormatModuleName)
#>
<#+
string FormatModuleName(TsModel module) {
var parts = module.Name.Split(new []{'.'});
var newName = parts[parts.Length - 1];
return newName;
}
#>
2ooom source
share