This is a tool that consumes your C# domain models and types and creates TypeScript declaration files from them. There's other tools that does this but what makes this one different is that it internally uses Roslyn (the .NET compiler platform) to parse the source files, which removes the need to create and maintain our own parser.
$ npm install --save csharp-models-to-typescript
{
"include": [
"./models/**/*.cs",
"./enums/**/*.cs"
],
"exclude": [
"./models/foo/bar.cs"
],
"namespace": "Api",
"output": "./api.d.ts",
"camelCase": false,
"camelCaseEnums": false,
"camelCaseOptions": {
"pascalCase": false,
"preserveConsecutiveUppercase": false,
"locale": "en-US"
},
"numericEnums": false,
"omitFilePathComment": false,
"omitSemicolon": false,
"stringLiteralTypesInsteadOfEnums": false,
"customTypeTranslations": {
"ProductName": "string",
"ProductNumber": "string"
}
}
"scripts": {
"generate-types": "csharp-models-to-typescript --config=your-config-file.json"
},
generate-types
and the output file specified in your config should be created and populated with your models.MIT © Jonathan Svenheden