I'm curious about using enum values in TypeScript to restrict the possible values for a variable. For example, I have an enum named FormType with Create and Update options. Is there a way to ensure that only these enum values are used?
enum FormType {
Create = 1,
Update = 2
}
// Is it possible to do something like this?
const a: FormType = FormType.Create // Preventing other values like 3 from being used
// Maybe something like this instead?
const a: FormType.Create | FormType.Update = FormType.Create