Creates a MaybeTypeGuard that checks that the value is either null or of type T.
MaybeTypeGuard
null
T
Can be shortened with TypeGuard.maybe.
TypeGuard.maybe
The type to make nullable
The type guard for the base type T
A type guard for T | null
T | null
const isMaybeNumber = isMaybe(isNumber); // or isNumber.maybe()isMaybeNumber(5); // trueisMaybeNumber(null); // trueisMaybeNumber("hello"); // false Copy
const isMaybeNumber = isMaybe(isNumber); // or isNumber.maybe()isMaybeNumber(5); // trueisMaybeNumber(null); // trueisMaybeNumber("hello"); // false
Creates a
MaybeTypeGuardthat checks that the value is eithernullor of typeT.Can be shortened with
TypeGuard.maybe.