Convert enum.js to ts

This commit is contained in:
RMidhunSuresh 2021-11-17 15:50:04 +05:30
parent 0e18247184
commit ebd1caf6d1

View file

@ -14,12 +14,9 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
export function createEnum(...values) { export function createEnum(...values: string[]): Readonly<{}> {
const obj = {}; const obj = {};
for (const value of values) { for (const value of values) {
if (typeof value !== "string") {
throw new Error("Invalid enum value name" + value?.toString());
}
obj[value] = value; obj[value] = value;
} }
return Object.freeze(obj); return Object.freeze(obj);