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
? NullishEmpty<GenericInput>
: NullishFilled<GenericInput>;Parameters
input: Value to wrap (null,undefined, or any other value).
Return value
NullishFilledwhen the value exists.NullishEmptywhen the value isnullorundefined.
