Type Alias IsNumberLiteral<T, $O>

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

🎭 predicate

Validate if T is number literals.

Type Parameters

type R = IsNumberLiteral<number> // false
type R = IsNumberLiteral<1> // true

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

type R = IsNumberLiteral<string | 1> // boolean

🔢 customize

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

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

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

type R = IsNumberLiteral<string | 1> // 1

🔢 customize:

Disable distribution of union types.

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

🔢 customize

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

type R = IsNumberLiteral<1, $SelectionBranch> // $Then
type R = IsNumberLiteral<string, $SelectionBranch> // $Else