An invariant function takes a value, and if the value is falsy then the invariant function will throw. If the value is truthy, then the function will not throw.

// Type Narrowing
const value: Person | null = { name: "Alex" }
invariant(value, "Expected value to be a person")
// type of value has been narrowed to 'Person'
function minimalInvariant(condition: any, message: string): asserts condition {
  if (!condition) {
    throw new Error(message)
  }
}

Thanks