/** Throws if argument is null/undefined. */ export function expectNotNull(val: T | null | undefined): T { if (val === null || val === undefined) { throw Error("Unexpected missing value."); } return val as T; } //* Throws if argument is not truthy. */ export function assert(val: T): asserts val { if (!val) { throw Error("Assertion failed."); } }