Skip to content
Single-class-per-file C# to TypeScript generator
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs re-created build-publish.ps1, updated Release steps.txt Dec 27, 2018
nuget-dotnetcli
nuget
src/TypeGen
.gitattributes Initial commit Jun 25, 2016
.gitignore
LICENSE updated license info Jul 7, 2018
README.md small docs change - replaced "property types" with "types" Jan 10, 2019
appveyor.yml build fix Dec 22, 2018
build-publish.ps1
nuget-update.ps1 nuget update 2.3.1 May 18, 2019
version-update.ps1

README.md

TypeGen

Single-class-per-file C# to TypeScript generator

Build status

Project's website: http://jburzynski.net/TypeGen

Complete documentation: http://typegen.readthedocs.io

How to get

Quick start

Add TypeGen NuGet package to your project.

Mark your C# classes/enums as exportable to TypeScript:

// with attributes

[ExportTsClass]
public class ProductDto
{
    public decimal Price { get; set; }
    public string[] Tags { get; set; }
}

// or with a generation spec

public class MyGenerationSpec : GenerationSpec
{
    public MyGenerationSpec()
    {
        AddClass<ProductDto>();
    }
}

After building your project, type TypeGen generate into the Package Manager Console (you might need to restart Visual Studio), or dotnet typegen generate in the system console if you're using TypeGen .NET CLI tool. Note: if you're using generation specs, you should also add your spec(s) in tgconfig.json under the generationSpecs parameter (more details in the docs).

This will generate a single TypeScript file (named product-dto.ts) in your project directory. The file will look like this:

export class ProductDto {
    price: number;
    tags: string[];
}

Features

Some of TypeGen's features include:

  • generating TypeScript classes, interfaces and enums - single class per file
  • support for collection (or nested collection) types
  • generic classes/types generation
  • support for inheritance
  • customizable convertion between C#/TypeScript names (naming conventions)

For complete list of features with examples, please refer to the project's documentation: http://typegen.readthedocs.io

You can’t perform that action at this time.