Type Alias IsObject<T, $O>

IsObject<T, $O>: $SpecialType<T, $MergeOptions<$O, {
    $else: IsObject.$<T, $O>;
    $then: $ResolveBranch<T, $O, [$Else]>;
}>>

🎭 predicate

Validate if T is an object or object literals.

Note that Function, Array, and tuple are also objects.

Type Parameters

type R = IsNotObject<object> // true
type R = IsObject<{}> // true
type R = IsObject<{ a: 1 }> // true
type R = IsObject<Function> // true

type R = IsObject<never> // false
type R = IsObject<unknown> // false
type R = IsObject<number> // false

type R = IsObject<{} | bigint> // boolean

🔢 customize

Filter to ensure T is an object or object literals, otherwise returns never.

type R = IsObject<{}, { selection: 'filter' }> // {}
type R = IsObject<{ a: 1 }, { selection: 'filter' }> // { a: 1 }
type R = IsObject<Function, { selection: 'filter' }> // Function

type R = IsObject<never, { selection: 'filter' }> // never
type R = IsObject<unknown, { selection: 'filter' }> // never

type R = IsObject<{} | bigint> // {}

🔢 customize:

Validate if T is exactly object.

type R = IsObject<object, { exact: true }> // true
type R = IsObject<{}, { exact: true }> // false

🔢 customize:

Disable distribution of union types.

type R = IsObject<{} | 1> // boolean
type R = IsObject<{} | 1, { distributive: false }> // false

🔢 customize

Use unique branch identifiers to allow precise processing of the result.

type R = IsObject<{}, $SelectionBranch> // $Then
type R = IsObject<string, $SelectionBranch> // $Else