import { type Empty } from "https://deno.land/x/eitherway@0.10.0/lib/core/mod.ts";
An artificial bottom type en lieu of unknown and nullish types
This is used as a combatibility safe-guard for conversions between
Result<T, E>
and Option<T>
, where a value of type Ok<void>
would evaluate to None
when converted with .ok()
.
Examples
Example 1
Example 1
import { assert } from "./assert.ts";
import { Empty, Ok, Option, Result, Some } from "./mod.ts";
const voidResult: Result<void, never> = Ok(undefined);
const emptyResult: Result<Empty, never> = Ok.empty();
assert(voidResult.ok().isNone() === true);
assert(emptyResult.ok().isNone() === false);