@dxos/echo
    Preparing search index...

    Variable instanceOfConst

    instanceOf: {
        <T extends Type.Type<unknown>>(
            type: T,
            _hint?: undefined,
            ..._error: [
                "ERROR: Obj.instanceOf does not accept Type.Type; use Type.isType(value) instead",
            ],
        ): never;
        <R extends AnyRelation>(
            type: R,
            _hint?: undefined,
            ..._error: [
                "ERROR: Obj.instanceOf does not accept relation types; use Relation.instanceOf instead",
            ],
        ): never;
        <S extends AnyObj>(schema: S): (value: unknown) => value is InstanceType<S>;
        <S extends AnyObj>(schema: S, value: unknown): value is InstanceType<S>;
    } = ...

    Test if an object is an instance of a given object type.

    Type declaration

      • <T extends Type.Type<unknown>>(
            type: T,
            _hint?: undefined,
            ..._error: [
                "ERROR: Obj.instanceOf does not accept Type.Type; use Type.isType(value) instead",
            ],
        ): never
      • Type Parameters

        Parameters

        • type: T
        • Optional_hint: undefined
        • ..._error: [
              "ERROR: Obj.instanceOf does not accept Type.Type; use Type.isType(value) instead",
          ]

        Returns never

      • <R extends AnyRelation>(
            type: R,
            _hint?: undefined,
            ..._error: [
                "ERROR: Obj.instanceOf does not accept relation types; use Relation.instanceOf instead",
            ],
        ): never
      • Type Parameters

        Parameters

        • type: R
        • Optional_hint: undefined
        • ..._error: [
              "ERROR: Obj.instanceOf does not accept relation types; use Relation.instanceOf instead",
          ]

        Returns never

      • <S extends AnyObj>(schema: S): (value: unknown) => value is InstanceType<S>
      • Type Parameters

        Parameters

        • schema: S

        Returns (value: unknown) => value is InstanceType<S>

      • <S extends AnyObj>(schema: S, value: unknown): value is InstanceType<S>
      • Type Parameters

        Parameters

        • schema: S
        • value: unknown

        Returns value is InstanceType<S>

    const john = Obj.make(Person, { name: 'John' });
    const isPerson = Obj.instanceOf(Person);
    if (isPerson(john)) {
    // john is Person
    }

    Only accepts Type.AnyObj — use Relation.instanceOf for relations and Type.isType(value) to test for Type.Type meta-schema entities.

    O(1) type-URI comparison with a typename fallback; no schema validation.