API reference@evolu/commonTypes › isInstance

function isInstance<Value>(
  name: Value["~evolu/instance"],
): (value: unknown) => value is Value;

Defined in: packages/common/src/Types.ts:247

Creates a realm-neutral predicate for one Instance name.

The identity must be stored directly on the value; inherited markers are ignored.

The explicit value type can include the rest of an interface whose trusted constructors attach the matching identity.

Checking runtime identity

import { assertTrue, instance, isInstance, type Instance } from "@evolu/common";

interface Foo extends Instance<"Foo"> {
  readonly value: string;
}

const isFoo = isInstance<Foo>("Foo");
const value: unknown = { ...instance("Foo"), value: "value" };

assertTrue(isFoo(value));