@adrianhall/cloudflare-toolkit
@adrianhall/cloudflare-toolkit / index / throwIfNull
Function: throwIfNull()
throwIfNull<
T>(value,message):asserts value is NonNullable<T>
Defined in: src/lib/guards/guards.ts:19
Assert that value is neither null nor undefined. A genuine TypeScript assertion function: once called, TypeScript narrows value to NonNullable<T> for the rest of the calling scope, so callers get type narrowing for free instead of needing a separate if/cast.
Type Parameters
T
T
Parameters
value
T
The value to check.
message
string
Human-readable explanation of what was unexpectedly null/undefined. Forwarded as-is to the thrown NullError.
Returns
asserts value is NonNullable<T>
Throws
If value is null or undefined.