Skip to content

houfeng0923/babel-plugin-iterable-enum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

babel-plugin-iterable-enum

Make typescript enum iterable.

Install

Using npm:

npm install --save-dev babel-plugin-iterable-enum

or using yarn:

yarn add babel-plugin-iterable-enum --dev

Usage

.babelrc

{
  "plugins": ["iterable-enum", "@babel/transform-typescript"]
}

Output

// Before

enum Direction { Left, Right, Down, Up };

// After

const Direction = {
  Left: 0,
  Right: 1,
  Down: 2,
  Up: 3,
  '__proto__': {
    0: 'Left',
    1: 'Right',
    2: 'Down',
    3: 'Up'
  }
};

// so, we can iterable enum using `Object.keys(Direction)`

About

make typescript enum iterable

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published