Your goal can be fullfilled with writing simple code generator and/or attribute. (Please update to version 1.4.1 if you already use fluent configuration).
Consider following attribute:
using Reinforced.Typings;
using Reinforced.Typings.Ast;
using Reinforced.Typings.Attributes;
using Reinforced.Typings.Fluent;
using Reinforced.Typings.Generators;
public class LegacySupportAttribute: TsPropertyAttribute
{
public LegacySupportAttribute()
{
this.ShouldBeCamelCased = true;
this.CodeGeneratorType = typeof(LegacyPropertyDuplicator);
}
}
The LegacyPropertyDuplicator is RT's property code generator, written like that:
public class LegacyPropertyDuplicator : PropertyCodeGenerator
{
/// <summary>
/// Main code generator method. This method should write corresponding TypeScript code for element (1st argument) to
/// WriterWrapper (3rd argument) using TypeResolver if necessary
/// </summary>
/// <param name="element">Element code to be generated to output</param>
/// <param name="result">Resulting node</param>
/// <param name="resolver">Type resolver</param>
public override RtField GenerateNode(MemberInfo element, RtField result, TypeResolver resolver)
{
var b = base.GenerateNode(element, result, resolver);
if (b == null) return null;
var pascalCaseName = b.Identifier.IdentifierName.Substring(0, 1).ToUpperInvariant()
+ b.Identifier.IdentifierName.Substring(1);
var newField = new RtField()
{
AccessModifier = b.AccessModifier,
Identifier = new RtIdentifier(pascalCaseName),
InitializationExpression = b.InitializationExpression,
IsStatic = b.IsStatic,
Documentation = b.Documentation,
Order = b.Order,
Type = b.Type
};
if (Context.Location.CurrentClass != null) Context.Location.CurrentClass.Members.Add(newField);
if (Context.Location.CurrentInterface != null) Context.Location.CurrentInterface.Members.Add(newField);
return b;
}
}
Then use this attribute like that:
public class TestClass
{
[LegacySupport]
public string LastName { get; set; }
}
And get following result:
export interface ITestClass
{
lastName: string;
LastName: string;
}
You also can specify code generator within fluent configuration:
public static void Configure(ConfigurationBuilder cb)
{
cb.ExportAsInterface<TestClass>()
.WithPublicProperties()
.WithProperty(x => x.LastName, x => x.WithCodeGenerator<LegacyPropertyDuplicator>());
}