TypeGen is a single-class-per-file C# to TypeScript generator. Out of the box are available 2 utilities:
// use attribute on the type you want to generate
[ExportTsClass]
public class ProductDto
{
public decimal Price { get; set; }
public string[] Tags { get; set; }
}
// ...or use a generation spec
public class MyGenerationSpec : GenerationSpec
{
public MyGenerationSpec()
{
AddClass<ProductDto>();
}
}
// inside "product-dto.ts"
export class ProductDto {
price: number;
tags: string[];
}
TypeGen allows you to generate TypeScript classes / interfaces / enums from C# classes and enums.
Every C# type is generated to a separate TypeScript file, to a location of your choice.
By default, all IEnumerable and IDictionary types are represented as TypeScript arrays and dictionaries.
You can translate your generic type definitions to TS. Generic types can also be used for properties and fields.
Inheritance chains of any length can be represented in the generated TypeScript sources.
C# primitive types (int, string etc.) are by default translated to their corresponding TypeScript counterparts.
You can exclude (ignore) certain properties or fields from being generated to TypeScript.
Code style-related aspects, such as: tab size, string literal sign etc. can be customized.
You can include custom TypeScript code inside the generated sources and prevent it from being overridden.
You can define your own custom logic for converting C# type/member names to TypeScript.
TypeGen CLI can be configured to automatically add generated TS sources to your ASP.NET MVC project file.
Last but not least, TypeGen is - and will always be - free!