Convert enum.js to ts

This commit is contained in:
RMidhunSuresh 2021-11-17 15:50:04 +05:30
parent 0e18247184
commit ebd1caf6d1
1 changed files with 1 additions and 4 deletions

View File

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