Checks if a value is Optional.
Absence is accepted on its own: undefined passes without consulting the guard, while every other value, null included, must satisfy it. Suited to optional fields in isObject templates, where a missing property and a valid one are equally acceptable.
undefined
null
The type validated by the type guard
The value to check
A type guard function to validate the value if it is not undefined
True if the value is undefined or satisfies the type guard; false otherwise
Checks if a value is Optional.
Absence is accepted on its own:
undefinedpasses without consulting the guard, while every other value,nullincluded, must satisfy it. Suited to optional fields in isObject templates, where a missing property and a valid one are equally acceptable.