Narrow a value from outside the type system — JSON, an env var, an API payload — to one of an
allowed set, returning undefined for anything else.
Prefer this over a cast: a value the source invented is dropped rather than passed on as a member
it is not, so an invalid value fails where it enters instead of somewhere downstream.
Narrow a value from outside the type system — JSON, an env var, an API payload — to one of an allowed set, returning
undefinedfor anything else.Prefer this over a cast: a value the source invented is dropped rather than passed on as a member it is not, so an invalid value fails where it enters instead of somewhere downstream.