Enum factory in typed JavaScript