nullish
Transforms a potentially null/undefined value into an Either. Allows propagating presence/absence in a type-safe way.
Interactive example
Syntax
typescript
function nullish<const GenericInput extends unknown = undefined>(
input: GenericInput
): GenericInput extends NullishValue
? EitherNullishEmpty<GenericInput>
: EitherNullishFilled<GenericInput>;Parameters
input: Value to wrap (null,undefined, or any other value).
Return value
EitherNullishFilledwhen the value exists.EitherNullishEmptywhen the value isnullorundefined.
