This seems like a simple question but I haven't found an answer or more likely I'm not sure the correct thing to look up.
In my typescript code I have a type called Determiner
that resembles the following:
type Determiner = 'a' | 'an' | 'the' | '' | 'auto';
In my code I have a variable of type Determiner
and I am reassigning it based on the value of another variable that is of type string
.
let determiner: Determiner = 'auto';
const content: string = getNewValue();
Right now the way I'm checking is a bit inefficient by using an if statement with all of the valid values.
if (
content === "a" ||
content === "an" ||
content === "the" ||
content === "" ||
content === "auto"
) {
determiner = content;
}
While this works, I'm wondering if there's an easier to perform this check without enumerating all of the possible values manually.