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
? OptionalEmpty
: OptionalFilled<GenericInput>;Parameters
input: Can beundefinedor a concrete value.
Return value
OptionalFilledif the value is defined.OptionalEmptyotherwise.
