Skip to content

assert

Asserts that a condition is true. Throws if it is not.

Use in place of /* v8 ignore *\/ for defensive guards that should never trigger at runtime but would otherwise create uncovered branches.

Import:

import { assert } from 'obsidian-dev-utils/type-guards';

Signature:

function assert(condition: boolean, errorOrMessage: string | Error): void

Parameters:

ParameterTypeDescription
conditionbooleanThe condition to assert.
errorOrMessagestring | ErrorThe error or message to throw if the condition is false.

Returns: void