MateusTech.ModelGenerator.Typescript
1.0.0-alpha
dotnet add package MateusTech.ModelGenerator.Typescript --version 1.0.0-alpha
NuGet\Install-Package MateusTech.ModelGenerator.Typescript -Version 1.0.0-alpha
<PackageReference Include="MateusTech.ModelGenerator.Typescript" Version="1.0.0-alpha" />
<PackageVersion Include="MateusTech.ModelGenerator.Typescript" Version="1.0.0-alpha" />
<PackageReference Include="MateusTech.ModelGenerator.Typescript" />
paket add MateusTech.ModelGenerator.Typescript --version 1.0.0-alpha
#r "nuget: MateusTech.ModelGenerator.Typescript, 1.0.0-alpha"
#:package MateusTech.ModelGenerator.Typescript@1.0.0-alpha
#addin nuget:?package=MateusTech.ModelGenerator.Typescript&version=1.0.0-alpha&prerelease
#tool nuget:?package=MateusTech.ModelGenerator.Typescript&version=1.0.0-alpha&prerelease
Model Generator
This library aims to generate Typescript interfaces from many programming languages.
In the backend development it is very common to create DTOs (Data Transfer Objects) to represent the data that is being sent or received by the API. It is also very common to have models that generate database migrations. This library generates Typescript interfaces for frontend (whether it is to be used in React, Angular, or any other web frameworks) from the backend.
Usage
// Import statements
// ...
namespace ExampleUsage;
class Program
{
private static DirectoryInfo? TryGetSolutionDirectoryInfo(string? currentPath = null)
{
var directory = new DirectoryInfo(
currentPath ?? Directory.GetCurrentDirectory()
);
while (directory != null && !directory.GetFiles("*.sln").Any())
{
directory = directory.Parent;
}
return directory;
}
public static void Main()
{
var directory = TryGetSolutionDirectoryInfo();
if (directory != null)
{
var typescriptOutPath = $"{directory}/ExampleUsage/Out";
var csharpModelsPaths = new List<string>
{
$"{directory}/ExampleUsage/Models"
};
var outSubFolders = new List<string>
{
"addresses",
"products",
"orders",
"payments",
"customers",
"categories",
};
var convertModels = new ConvertModels(
typescriptOutPath: typescriptOutPath,
csharpModelsPaths: csharpModelsPaths,
outSubFolders: outSubFolders
);
convertModels.GenerateTypeScriptInterfaces();
}
}
}
To get started, you must provide the paths to the C# models and the path where the Typescript interfaces will be generated. The outSubFolders parameter is optional and it is used to aggregate the interfaces in subfolders.
We have a base class called ConvertModels and at this class we have exposed methods to convert to either interfaces, types or classes in typescript. You can also find this example at ExampleUsage C# project.
Contributing
If you want to contribute to this project, please read the CONTRIBUTING.md file.
License
This project is licensed under the MIT License - see the LICENSE file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Microsoft.CodeAnalysis.CSharp (>= 4.13.0)
- PluralizeService.Core (>= 1.2.21147.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-alpha | 192 | 3/13/2025 |
Initial alpha release.