Function: assertDefined()
ts
function assertDefined<T>(
value: Nillable<T>,
format?: string, ...
rest: AnyArgs): asserts value is T;Assertion function to ensure provided value is not nil.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
value | Nillable<T> | undefined | Value to check. |
format | string | "Type assertion failed, unexpected 'nil' value provided." | Optional C-like formatted string for interpolation. |
...rest | AnyArgs | undefined | Rest parameters to interpolate into format string. |
Returns
asserts value is T
Remarks
@inline keeps the happy path as a local if check and avoids a function call at runtime.