CommonProps Documentation - v0.1.2
    Preparing search index...

    Type Alias IsUpcastable<T>

    IsUpcastable: [T] extends [string]
        ? string extends T ? false : true
        : [T] extends [number]
            ? number extends T ? false : true
            : [T] extends [boolean]
                ? true extends T ? false extends T ? false : true : true
                : false

    Determines if a type can be upcast to its primitive base type.

    Returns true for literal types (e.g., 'hello', 42, true) that can be upcast to their primitive base (string, number, boolean). Returns false for primitive base types and non-primitive types.

    Uses non-distributive conditionals to handle union types correctly.

    Type Parameters

    • T

      The type to check

    true if the type is a primitive literal, false otherwise

    type A = IsUpcastable<'hello'>;   // true
    type B = IsUpcastable<string>; // false
    type C = IsUpcastable<42>; // true
    type D = IsUpcastable<number>; // false
    type E = IsUpcastable<boolean>; // false