I want to create an enum with a range of numbers from 1 to 200.
There are too many to list all of them one by one, so I want to use a function like range
.
export enum NumberData {
// ???
}
In the code above ???
,
Please tell me what code to put inside.
Probably, is not possible. Because enums in TypeScript translates to function in javascript (not arrays). You can't automatically fill fields inside a function. You can fill only arrays
enum NumberData {
ONE = 1,
TWO = 2
}
// translates to =>
"use strict";
var NumberData;
(function (NumberData) {
NumberData[NumberData["ONE"] = 1] = "ONE";
NumberData[NumberData["TWO"] = 2] = "TWO";
})(NumberData || (NumberData = {}));