Evercatch - v0.10.0
    Preparing search index...

    Type Alias NotNullish<E>

    NotNullish: [Extract<E, null | undefined>] extends [never] ? unknown : never

    Constraint that rejects error types that could be nullish.

    null in the error slot means "this result is ok, there is no error", so an error can never be null. undefined is rejected along with it, since it means "no error was passed" everywhere an error is optional.

    Every error type in this library is constrained with it. Use it when writing your own generic helpers around Result.

    unknown is allowed, so an error caught in a catch block can be passed on as is. any is not, since it resolves to a nullish type here; widen it to unknown instead.

    Type Parameters

    • E

      The type of the error.

    function logError<E extends NotNullish<E>>(result: Result<unknown, E>) {
    const [error] = result;
    if (error) {
    console.error(error);
    }
    }