optional
Wraps an undefined/defined value in an Either, useful for propagating optional fields.
Interactive example
Syntax
typescript
function optional<
const GenericInput extends unknown = undefined
>(
input: GenericInput
): GenericInput extends undefined
? EitherOptionalEmpty
: EitherOptionalFilled<GenericInput>;Parameters
input: Can beundefinedor a concrete value.
Return value
EitherOptionalFilledif the value is defined.EitherOptionalEmptyotherwise.
