Only undefined is rejected: null and falsy values such as 0, "", and false are all defined. On success the
value narrows to its declared type without undefined, so the guard doubles as a filtering predicate, as in
values.filter(value => isDefined(value)).
A type guard may be supplied to constrain the value beyond mere presence: absence is rejected on its own, whether or
not the guard would admit it, so the value narrows to the guarded type stripped of undefined, and a guard built
over an Optional type is confined to its present values.
Type Parameters
T
The type validated by the type guard, or unknown where no guard is given
Checks if a value is Defined.
Only
undefinedis rejected:nulland falsy values such as0,"", andfalseare all defined. On success the value narrows to its declared type withoutundefined, so the guard doubles as a filtering predicate, as invalues.filter(value => isDefined(value)).A type guard may be supplied to constrain the value beyond mere presence: absence is rejected on its own, whether or not the guard would admit it, so the value narrows to the guarded type stripped of
undefined, and a guard built over an Optional type is confined to its present values.