If I have a TypeScript union like so:
type SomeUnion = 'Foo' | 'Bar' | 'Baz';
Is there a way I can convert this into a string-based enum? Like the the following:
enum SomeUnionBasedEnum {
Foo = 'Foo',
Bar = 'Bar',
Baz = 'Baz'
}
I am trying to model an enum that represents the permissions in our system, but those permissions are in some cases automatically generated union types. I want a way to combine them into a single enum because enums provide a better developer experience by limiting the intellisense to the permissible values. For example AppPermisionEnum.<available enum values>. I'd also be open to ways to combine enums into a single enum, but I don't think that's possible. My end goal is to have an enum comprised of values from a couple different sources.