sb-cs2ts
v1.0.1
Published
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)](https://
Downloads
4
Readme
C# models to TypeScript
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.
Dependencies
Forked from
- https://github.com/svenheden/csharp-models-to-typescript
Install
$ npm install --save --dev sb-cs2ts
How to use
- Add a config file to your project that contains for example...
{
"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,
"stringLiteralTypesInsteadOfEnums": false,
"customTypeTranslations": {
"ProductName": "string",
"ProductNumber": "string"
}
}
- Add a npm script to your package.json that references your config file...
"scripts": {
"generate-ts": "cs2ts --config=your-config-file.json"
},
- Run the npm script
generate-ts
and the output file specified in your config should be created and populated with your models.
License
MIT © Jonathan Svenheden