API Reference / @evolu/common / Assert

Assert

🚨

This module provides assertion utilities to prevent invalid states from propagating through the system by halting execution when a condition fails, improving reliability and debuggability.

Warning: Do not use this instead of Type. Assertions are intended for conditions that are logically guaranteed but not statically known by TypeScript, or for catching and signaling developer mistakes eagerly (e.g., invalid configuration).

Variables

VariableDescription
assertEnsures a condition is true, throwing an error with the provided message if not.
assertNonEmptyArrayAsserts that an array is non-empty.
assertNonEmptyReadonlyArrayAsserts that a readonly array is non-empty.

Functions

FunctionDescription
assertNoErrorInCatchAsserts no error reaches a .catch block, throwing a developer error if it does. Used in Promise chains where errors indicate bugs to be fixed.

Was this page helpful?