Socket
Socket
Sign inDemoInstall

csharp-models-to-typescript

Package Overview
Dependencies
1
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    csharp-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)](https://


Version published
Weekly downloads
432
decreased by-28.95%
Maintainers
1
Install size
36.9 kB
Created
Weekly downloads
 

Readme

Source

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.

NPM version

Dependencies

Install

$ npm install --save csharp-models-to-typescript

How to use

  1. 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,
    "omitFilePathComment": false,
    "omitSemicolon": false,
    "stringLiteralTypesInsteadOfEnums": false,
    "customTypeTranslations": {
        "ProductName": "string",
        "ProductNumber": "string"
    }
}
  1. Add a npm script to your package.json that references your config file...
"scripts": {
    "generate-types": "csharp-models-to-typescript --config=your-config-file.json"
},
  1. Run the npm script generate-types and the output file specified in your config should be created and populated with your models.

License

MIT © Jonathan Svenheden

FAQs

Last updated on 22 Mar 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc