TypeScripter
TypeScripter copied to clipboard
Add ability to make all properties camel case
In C# the convention is to use UpperCamelCase for property names. In JavaScript/Typescript however, the convention is to use lowerCamelCase. Currently, TypeScripter outputs property names exactly as is, which causes some friction on the front end in Typescript. This PR adds the ability to opt in to using lowerCamelCase for property names.
Note: I tried following the coding style as best I could.
After digging through the source code some more, I realize that this is possible to do with formatters:
public class LowerCamelCaseFormatter : TsFormatter
{
public override string Format(TsProperty property)
{
var result = base.Format(property);
return char.ToLower(result[0]) + (result.Length == 1 ? String.Empty : result.Substring(1));
}
}
I'll leave this open for now, but feel free to close if you feel that a custom formatter is the preferred approach