ts-data-forge
    Preparing search index...

    Variable isNonNullObjectConst

    isNonNullObject: (u: unknown) => u is object

    Type guard that checks if a value is a non-null object.

    This function checks if a value has type "object" according to the typeof operator and is not null. This includes all object types such as plain objects, arrays, dates, regular expressions, and other object instances, but excludes functions.

    Type Narrowing Behavior:

    • Narrows unknown to object
    • Excludes null, undefined, and all primitive types
    • Excludes functions (they have typeof === "function", not "object")
    • Includes arrays, dates, regex, and other object instances

    Note: This function returns true for arrays. If you need record-oriented narrowing that excludes arrays, use isRecord() instead.

    Type Declaration

      • (u: unknown): u is object
      • Parameters

        • u: unknown

          The value to check

        Returns u is object

        true if u is an object and not null, false otherwise. When true, TypeScript narrows the type to object.

    const mixed: readonly unknown[] = [{ id: 1 }, null, 'Ada'] as const;

    const objects = mixed.filter(isNonNullObject);

    assert.deepStrictEqual(objects, [{ id: 1 }]);

    isRecord - For record-oriented type narrowing (excludes arrays)