ts-interface-enum

Converts typescript interfaces to enums.


Keywords
typescript, interface, enum
License
MIT
Install
npm install ts-interface-enum@1.3.3

Documentation

TsInterfaceEnum

NPM version Downloads

Converts typescript interfaces to enums

Pre-requisites

Use of typescript in your code

Install

npm i ts-interface-enum --save--dev

Config

Config file

In your root directory create a file called interface-enum.config.json The json should look as follows

{
  "paths": [
    "./app/model/schemes"
  ]
}

Mark interfaces

For each interface to convert add comment one line above For now only interface with export are supported due to new file created.

// my file /app/model/schemes/main.schemes.ts

// generateInterfaceToEnum
export interface IMySchemaInterface {
    id: number;
    moreData: string;
}


Usage

Call the module from where your code, works well inside gulp or npm as pre build script. Afterwards a new file will be created in the same directory of the found interface with the name of [foundTsFile].interfaceEnums.ts On re-run if the file was found to generate again it will be deleted.

License

MIT © Tomer Barnea