Type Alias IsNull<T, $O>

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

🎭 predicate

Validate if T is null.

Type Parameters

type R = IsNull<null> // true

type R = IsNull<never> // false
type R = IsNull<unknown> // false
type R = IsNull<string | boolean> // false

type R = IsNull<string | null> // boolean

🔢 customize

Filter to ensure T is null, otherwise returns never.

type R = IsNull<null, { selection: 'filter' }> // null

type R = IsNull<never, { selection: 'filter' }> // never
type R = IsNull<unknown, { selection: 'filter' }> // never
type R = IsNull<string | boolean, { selection: 'filter' }> // never

type R = IsNull<string | null> // null

🔢 customize:

Disable distribution of union types.

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

🔢 customize

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

type R = IsNull<null, $SelectionBranch> // $Then
type R = IsNull<string, $SelectionBranch> // $Else