API reference@evolu/commonlocal‑first/Timestamp › TimestampCounterOverflowError

Defined in: packages/common/src/local-first/Timestamp.ts:58

A TypeScript interface with a literal type property.

Use Typed for both domain objects in discriminated unions and plain domain errors returned by Result. Name a domain error interface XError. When X already describes a failure, use X for its type discriminant because Error describes the interface's role rather than the runtime error kind. Keep Error when it is needed to make the discriminant unambiguous, such as TimeoutError.

Typed unions model mutually exclusive states as separate variants instead of combinations of flags and optional properties. TypeScript narrows a union by its literal type property. To enforce exhaustive handling, return from every case of a value-producing switch or assert that the remaining value is never in the default case of a side-effecting switch.

Example

import {
  assertErr,
  assertOk,
  err,
  ok,
  type Result,
  type Typed,
} from "@evolu/common";

interface User extends Typed<"User"> {
  readonly id: string;
}

const getUser = (id: string): Result<User, UserNotFoundError> =>
  id === "user-1"
    ? ok({ type: "User", id })
    : err({ type: "UserNotFound", id });

interface UserNotFoundError extends Typed<"UserNotFound"> {
  readonly id: string;
}

assertOk(getUser("user-1"), { type: "User", id: "user-1" });
assertErr(getUser("missing"), { type: "UserNotFound", id: "missing" });

Extends

  • Typed<"TimestampCounterOverflowError">

Properties

type

readonly type: "TimestampCounterOverflowError";

Defined in: packages/common/src/Type.ts:11986

Inherited from

Typed.type