FuncType - v1.21.0
    Preparing search index...

    Function invariant

    • Asserts a condition that can only be false because of a bug, and narrows it for the code after it.

      Expected failures return Either; invariant is for the other kind — "upsert returned no row", "step must be non-negative", "AUTH_PROVIDER is required in production". It covers one statement, so a function can mix bug checks with Either-returning failure paths, and functype/prefer-either never sees a throw to report.

      invariant(row, "upsert returned no row")          // row: Row from here on
      invariant(teamDomain && aud, "requires CF_ACCESS_TEAM_DOMAIN and CF_ACCESS_AUD")
      invariant(n >= 0, () => `step must be non-negative, got ${n}`) // message built only on failure

      Parameters

      • condition: unknown

        Must be truthy. Narrowed to truthy after the call.

      • message: string | (() => string)

        The error message, or a thunk that builds it only when the check fails.

      Returns asserts condition

      InvariantViolation when condition is falsy.