API reference@evolu/commonAssert › assertType

const assertType: <T>(
  type: T,
  value: unknown,
  message?: string,
) => asserts value is InferType<T>;

Defined in: packages/common/src/Assert.ts:100

Ensures a value conforms to a Type.

Uses the Type name for the default error message.

Example

const length = buffer.getLength();

// We know length is logically non-negative, but TypeScript doesn't.
assertType(NonNegativeInt, length);