// Copyright 2025 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only export class AssertionError extends TypeError { override name = 'AssertionError'; } export function assert(condition: boolean, message?: string): asserts condition; export function assert(input: T, message?: string): NonNullable; export function assert(input: T, message?: string): NonNullable { if (input === false || input == null) { // oxlint-disable-next-line no-debugger debugger; // oxlint-disable-next-line typescript/restrict-template-expressions throw new AssertionError(message ?? `input is ${input}`); } return input; } export function unreachable(_value: never): never { // oxlint-disable-next-line no-debugger debugger; throw new AssertionError('unreachable'); }