unwrapRight
Unwraps the payload of a Right and returns the input unchanged when the input is not Right.
Interactive example
Syntax
typescript
function unwrapRight<
GenericInput extends unknown
>(
input: GenericInput
): GenericInput extends Right
? Unwrap<GenericInput>
: GenericInputParameters
input: Value to unwrap when it is aRight.
Return value
Returns the unwrapped payload for Right, otherwise returns input unchanged.
See also
unwrapRightOrThrow– Throwing variant when input is notRight.isRight– Type guard to check right side.unwrapByInformation– Information-based non-throwing unwrap.
