With that object, we then just need to get the keys of the enum, and lookup the values in the enum and the description in our extra object. Making statements based on opinion; back them up with references or personal experience. Generic enum converter to array list for Typescript, Convert a typescript enum into an array of enums, Angular2 reference enum in array in interface, how to map enum values to type in typescript, Map enum values to individual types in TypeScript. . What is the goal here? Here is my proposal, to build a simple structure that you can implement quickly. Thanks again @TitianCernicova-Dragomir, Mapping all enum values to array of interface in TypeScript, How terrifying is giving a conference talk? Multiplication implemented in c++ with constant time. Adding salt pellets direct to home water tank. If the command runs successfully, the result will be the below JSON object that represents the generated JSON Schema: Get your tech brand or product in front of software developers. Once suspended, devbyrayray will not be able to comment or publish posts until their suspension is removed. In the example, you can see that the console will output an Array. Considering a key/value enum, you can use the Object.entries to extract the data and create the array. By using dirask, you confirm that you have read and understood, TypeScript - ?? preact-cli during production bundle building, browserify, etc. Since TypeScript 1.8 you can use string literal types to provide a reliable and safe experience for named string values (which is partially what enums are used for). Lead Frontend/JavaScript Developer since 2009 Writing about CSS, JavaScript, Typescript, Angular, Serverless functions,, and a lot more web-related topics. To subscribe to this RSS feed, copy and paste this URL into your RSS reader. Yes, I know you are searching for a solution for turning your enum into a JavaScript Array. How to reference enum types in Typescript? typescriptlang.org/docs/handbook/enums.html, blog.mandraketech.in/typescript-string-enums, Keys, and string values that match the keys, Arrays of valid field names, that can be used for input validation, for example when you are dealing with http query strings and want to check if the parameter name is valid, String union types for use within the application code, for those places where you would have otherwise used. to your account, convert to: [{id: 1, name: 'dog'}, {id: 2, name: 'cat'}, {id: 3, name: 'ant'}]. 1 - Types of Typescript Enums. typescript enums Share Improve this question Follow asked May 8, 2019 at 8:23 Lehks 2,510 3 19 48 Add a comment 5 Answers Sorted by: 59 Yes, it is possible to use: Object.values (MyEnum) because enum is an JS object after compilation: var MyEnum; (function (MyEnum) { MyEnum ["FOO"] = "foo"; MyEnum ["BAR"] = "bar"; }) (MyEnum || (MyEnum = {})); Converting a TypeScript Enum to a JavaScript Array is pretty easy, and I often use it to fill a