An open API service indexing awesome lists of open source software.

https://github.com/qeepsake/ts-string-as-enum

Convert a string to an enum type with TypeScript ⚡️
https://github.com/qeepsake/ts-string-as-enum

Last synced: 12 months ago
JSON representation

Convert a string to an enum type with TypeScript ⚡️

Awesome Lists containing this project

README

          

# Convert String to Enum with TypeScript

Tiny (zero dependencies) utility to Convert string to enum type with TypeScript ⚡️
## Install

```bash
npm install --save @qeepsake/ts-string-as-enum
```

## Usage

```ts
export declare enum Colors {
/** JSDoc */
Blue = "Blue",
/** JSDoc */
Red = "Red",
/** JSDoc */
Green = "Green",
}

tsStringAsEnum(Colors, 'blue'); // -> Colors.Blue
```

## License

MIT © [lukebrandonfarrell](https://github.com/lukebrandonfarrell)
## Contributors ✨

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):



Luke Brandon Farrell

📆 💻

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!