Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/ahh/src/option/mod.ts>O.expect

Idiomatic type-safety structures for TypeScript.
Go to Latest
method O.expect
import { O } from "https://deno.land/x/ahh@v0.9.1/src/option/mod.ts";

Returns the contained Some value.

Throws if the Option is a None with the provided message.

Examples

import { O, None } from "./mod.ts";

console.log(O.expect(1, "returns")); // 1
O.expect(None, "throws"); // throws

Parameters

o: Option<T>
message: string

Returns

o extends Some<T> ? T : never