Skip to main content

optional

Callable


  • optional takes an arbitrary and returns an arbitrary that is either the original arbitrary or the optional symbol

    Example

    random(optional(integer()))
    // => Nothing

    random(optional(integer()))
    // => 1234

    random(optional(integer({symbol: undefined})))
    // => undefined

    Type parameters

    Parameters

    Returns Nothing extends O ? Dependent<Maybe<T>> : Dependent<O | T>

    An optional version of the given arbitrary.