Type Alias Assignable<A, B, $O>

Assignable<A, B, $O>: $SpecialType<B, {
    $any: $ResolveBranch<A, $O, [0 extends 1 & A
        ? $Any
        : unknown, $Then]>;
    $else: $SpecialType<A, {
        $any: $ResolveBranch<A, $O, [$Any, $Then]>;
        $else: Assignable.$<A, B, $O>;
        $never: $ResolveBranch<A, $O, [$Never, $Then]>;
        $unknown: $ResolveBranch<A, $O, [$Unknown, $Then]>;
    }>;
    $never: $ResolveBranch<A, $O, [A, never] extends [never, A]
        ? [$Never, $Then]
        : [$Else]>;
    $unknown: $ResolveBranch<A, $O, [[A, unknown] extends [unknown, A]
        ? $Unknown
        : unknown, $Then]>;
}>

🎭 predicate

Validate if A is assignable to B.

Type Parameters

type R = Assignable<any, any> // true
type R = Assignable<any, 1> // true
type R = Assignable<unknown, unknown> // true
type R = Assignable<never, never> // true
type R = Assignable<1, 1> // true
type R = Assignable<'a', 'a'> // true
type R = Assignable<'a', 'b'> // false
type R = Assignable<'a', string> // true

🔢 customize

Filter to ensure A is assignable to B.

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

🔢 customize

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

type R = Assignable<any, any, Assignable.$Branch> // $Then

🔢 customize

Override special types branch.

type R = Assignable<any, any, { $any: 1 }> // 1
type R = Assignable<unknown, any, { $unknown: 1 }> // 1
type R = Assignable<never, any, { $never: 1 }> // 1