Type Alias IsNumber<T, $O>

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

🎭 predicate

Validate if T is number or number literals.

Type Parameters

type R = IsNumber<number> // true
type R = IsNumber<1> // true

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

type R = IsNumber<string | number> // boolean

🔢 customize

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

type R = IsNumber<number, { selection: 'filter' }> // number
type R = IsNumber<1, { selection: 'filter' }> // 1

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

type R = IsNumber<string | number> // number

🔢 customize:

Disable distribution of union types.

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

🔢 customize

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

type R = IsNumber<number, $SelectionBranch> // $Then
type R = IsNumber<string, $SelectionBranch> // $Else