devtypes - v1.1.0
    Preparing search index...

    Type Alias Cast<T, U>

    Cast: T extends U ? T : U

    Cast a type while preserving assignability.

    Type Parameters

    • T

      Source type

    • U

      Target type

    Keeps the source type if it is assignable to the target type; otherwise, resolves to the target type.

    type A = Cast< string, string | number >;   // string
    type B = Cast< number, string | number >; // number
    type C = Cast< boolean, string | number >; // string | number