Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

661 B
Raw Blame
/* Copyright 2026 Marimo. All rights reserved. */
import { invariant } from "./invariant";
import { Logger } from "./Logger";

/**
 * Type-safe exhaustiveness check for discriminated unions.
 */
export function assertNever(x: never): never {
  invariant(false, `Unexpected object: ${x}`);
}

/**
 * Like assertNever, but logs the unexpected object to the console.
 * Useful for exhaustiveness checks but without throwing an error.
 */
export function logNever(x: never): void {
  Logger.warn(`Unexpected object: ${JSON.stringify(x)}`);
  // oxlint-ignore-next-line -- noVoidTypeReturn: function returns void but value is needed for exhaustiveness
  return x;
}