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
Variable | Description |
---|---|
assert | Ensures a condition is true, throwing an error with the provided message if not. |
assertNonEmptyArray | Asserts that an array is non-empty. |
assertNonEmptyReadonlyArray | Asserts that a readonly array is non-empty. |
Functions
Function | Description |
---|---|
assertNoErrorInCatch | Asserts no error reaches a .catch block, throwing a developer error if it does. Used in Promise chains where errors indicate bugs to be fixed. |